forked from aniani/vim
patch 8.2.1705: "verbose hi Name" reports incorrect info after ":hi clear"
Problem: "verbose hi Name" reports incorrect info after ":hi clear". Solution: Store the script context. (Antony Scriven, closes #6975)
This commit is contained in:
parent
77e5dcc36a
commit
e8df010498
@ -76,6 +76,7 @@ typedef struct
|
|||||||
int sg_deflink; // default link; restored in highlight_clear()
|
int sg_deflink; // default link; restored in highlight_clear()
|
||||||
int sg_set; // combination of SG_* flags
|
int sg_set; // combination of SG_* flags
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
|
sctx_T sg_deflink_sctx; // script where the default link was set
|
||||||
sctx_T sg_script_ctx; // script in which the group was last set
|
sctx_T sg_script_ctx; // script in which the group was last set
|
||||||
#endif
|
#endif
|
||||||
} hl_group_T;
|
} hl_group_T;
|
||||||
@ -746,7 +747,13 @@ do_highlight(
|
|||||||
{
|
{
|
||||||
hlgroup = &HL_TABLE()[from_id - 1];
|
hlgroup = &HL_TABLE()[from_id - 1];
|
||||||
if (dodefault && (forceit || hlgroup->sg_deflink == 0))
|
if (dodefault && (forceit || hlgroup->sg_deflink == 0))
|
||||||
|
{
|
||||||
hlgroup->sg_deflink = to_id;
|
hlgroup->sg_deflink = to_id;
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
|
hlgroup->sg_deflink_sctx = current_sctx;
|
||||||
|
hlgroup->sg_deflink_sctx.sc_lnum += SOURCING_LNUM;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (from_id > 0 && (!init || hlgroup->sg_set == 0))
|
if (from_id > 0 && (!init || hlgroup->sg_set == 0))
|
||||||
@ -1691,16 +1698,12 @@ highlight_clear(int idx)
|
|||||||
VIM_CLEAR(HL_TABLE()[idx].sg_font_name);
|
VIM_CLEAR(HL_TABLE()[idx].sg_font_name);
|
||||||
HL_TABLE()[idx].sg_gui_attr = 0;
|
HL_TABLE()[idx].sg_gui_attr = 0;
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEAT_EVAL
|
// Restore default link and context if they exist. Otherwise clears.
|
||||||
// Restore any default link.
|
|
||||||
HL_TABLE()[idx].sg_link = HL_TABLE()[idx].sg_deflink;
|
HL_TABLE()[idx].sg_link = HL_TABLE()[idx].sg_deflink;
|
||||||
// Clear the script ID only when there is no link, since that is not
|
#ifdef FEAT_EVAL
|
||||||
// cleared.
|
// Since we set the default link, set the location to where the default
|
||||||
if (HL_TABLE()[idx].sg_link == 0)
|
// link was set.
|
||||||
{
|
HL_TABLE()[idx].sg_script_ctx = HL_TABLE()[idx].sg_deflink_sctx;
|
||||||
HL_TABLE()[idx].sg_script_ctx.sc_sid = 0;
|
|
||||||
HL_TABLE()[idx].sg_script_ctx.sc_lnum = 0;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
source view_util.vim
|
source view_util.vim
|
||||||
source screendump.vim
|
source screendump.vim
|
||||||
source check.vim
|
source check.vim
|
||||||
|
source script_util.vim
|
||||||
|
|
||||||
func Test_highlight()
|
func Test_highlight()
|
||||||
" basic test if ":highlight" doesn't crash
|
" basic test if ":highlight" doesn't crash
|
||||||
@ -870,6 +871,39 @@ func Test_highlight_clear_restores_links()
|
|||||||
call assert_equal(HighlightArgs('aaa'), hl_aaa_ddd)
|
call assert_equal(HighlightArgs('aaa'), hl_aaa_ddd)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_highlight_clear_restores_context()
|
||||||
|
func FuncContextDefault()
|
||||||
|
hi def link Context ContextDefault
|
||||||
|
endfun
|
||||||
|
|
||||||
|
func FuncContextRelink()
|
||||||
|
" Dummy line
|
||||||
|
hi link Context ContextRelink
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
let scriptContextDefault = MakeScript("FuncContextDefault")
|
||||||
|
let scriptContextRelink = MakeScript("FuncContextRelink")
|
||||||
|
let patContextDefault = fnamemodify(scriptContextDefault, ':t') .. ' line 1'
|
||||||
|
let patContextRelink = fnamemodify(scriptContextRelink, ':t') .. ' line 2'
|
||||||
|
|
||||||
|
exec "source" scriptContextDefault
|
||||||
|
let hlContextDefault = execute("verbose hi Context")
|
||||||
|
call assert_match(patContextDefault, hlContextDefault)
|
||||||
|
|
||||||
|
exec "source" scriptContextRelink
|
||||||
|
let hlContextRelink = execute("verbose hi Context")
|
||||||
|
call assert_match(patContextRelink, hlContextRelink)
|
||||||
|
|
||||||
|
hi clear
|
||||||
|
let hlContextAfterClear = execute("verbose hi Context")
|
||||||
|
call assert_match(patContextDefault, hlContextAfterClear)
|
||||||
|
|
||||||
|
delfunc FuncContextDefault
|
||||||
|
delfunc FuncContextRelink
|
||||||
|
call delete(scriptContextDefault)
|
||||||
|
call delete(scriptContextRelink)
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_highlight_default_colorscheme_restores_links()
|
func Test_highlight_default_colorscheme_restores_links()
|
||||||
hi link TestLink Identifier
|
hi link TestLink Identifier
|
||||||
hi TestHi ctermbg=red
|
hi TestHi ctermbg=red
|
||||||
|
@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1705,
|
||||||
/**/
|
/**/
|
||||||
1704,
|
1704,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user