Skip to content

Commit a5e0355

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 492ea88 + 890dd05 commit a5e0355

19 files changed

Lines changed: 384 additions & 25 deletions

runtime/colors/README.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Search for "highlight_init".
6464
If you think you have a color scheme that is good enough to be used by others,
6565
please check the following items:
6666

67+
- Source the check_colors.vim script to check for common mistakes.
6768
- Does it work in a color terminal as well as in the GUI?
6869
- Is "g:colors_name" set to a meaningful value? In case of doubt you can do
6970
it this way:

runtime/colors/check_colors.vim

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
" This script tests a color scheme for some errors. Load the scheme and source
2+
" this script. e.g. :e colors/desert.vim | :so test_colors.vim
3+
" Will output possible errors.
4+
5+
let s:save_cpo= &cpo
6+
set cpo&vim
7+
8+
func! Test_check_colors()
9+
call cursor(1,1)
10+
let err={}
11+
12+
" 1) Check g:colors_name is existing
13+
if !search('\<\%(g:\)\?colors_name\>', 'cnW')
14+
let err['colors_name'] = 'g:colors_name not set'
15+
else
16+
let err['colors_name'] = 'OK'
17+
endif
18+
19+
" 2) Check for some well-defined highlighting groups
20+
" Some items, check several groups, e.g. Diff, Spell
21+
let hi_groups = ['ColorColumn', 'Diff', 'ErrorMsg', 'Folded',
22+
\ 'FoldColumn', 'IncSearch', 'LineNr', 'ModeMsg', 'MoreMsg', 'NonText',
23+
\ 'Normal', 'Pmenu', 'Todo', 'Search', 'Spell', 'StatusLine', 'TabLine',
24+
\ 'Title', 'Visual', 'WarningMsg', 'WildMenu']
25+
let groups={}
26+
for group in hi_groups
27+
if search('\c@suppress\s\+'.group, 'cnW')
28+
" skip check, if the script contains a line like
29+
" @suppress Visual:
30+
let groups[group] = 'Ignoring '.group
31+
continue
32+
endif
33+
if !search('hi\%[ghlight] \+'.group, 'cnW')
34+
let groups[group] = 'No highlight definition for '.group
35+
continue
36+
endif
37+
if !search('hi\%[ghlight] \+'.group. '.*fg=', 'cnW')
38+
let groups[group] = 'Missing foreground color for '.group
39+
continue
40+
endif
41+
if search('hi\%[ghlight] \+'.group. '.*guibg=', 'cnW') &&
42+
\ !search('hi\%[ghlight] \+'.group. '.*ctermbg=', 'cnW')
43+
let groups[group] = 'Missing bg terminal color for '.group
44+
continue
45+
endif
46+
call search('hi\%[ghlight] \+'.group, 'cW')
47+
" only check in the current line
48+
if !search('guifg', 'cnW', line('.')) || !search('ctermfg', 'cnW', line('.'))
49+
" do not check for background colors, they could be intentionally left out
50+
let groups[group] = 'Missing fg definition for '.group
51+
endif
52+
call cursor(1,1)
53+
endfor
54+
let err['highlight'] = groups
55+
56+
" 3) Check, that it does not set background highlighting
57+
" Doesn't ':hi Normal ctermfg=253 ctermfg=233' also set the background sometimes?
58+
let bg_set='\(set\?\|setl\(ocal\)\?\) .*\(background\|bg\)=\(dark\|light\)'
59+
let bg_let='let \%([&]\%([lg]:\)\?\)\%(background\|bg\)\s*=\s*\([''"]\?\)\w\+\1'
60+
let bg_pat='\%('.bg_set. '\|'.bg_let.'\)'
61+
let line=search(bg_pat, 'cnW')
62+
if search(bg_pat, 'cnW')
63+
exe line
64+
if search('hi \U\w\+\s\+\S', 'cbnW')
65+
let err['background'] = 'Should not set background option after :hi statement'
66+
endif
67+
else
68+
let err['background'] = 'OK'
69+
endif
70+
call cursor(1,1)
71+
72+
" 4) Check, that t_Co is checked
73+
let pat = '[&]t_Co\s*[<>=]=\?\s*\d\+'
74+
if !search(pat, 'ncW')
75+
let err['t_Co'] = 'Does not check terminal for capable colors'
76+
endif
77+
78+
" 5) Initializes correctly, e.g. should have a section like
79+
" hi clear
80+
" if exists("syntax_on")
81+
" syntax reset
82+
" endif
83+
let pat='hi\%[ghlight]\s*clear\n\s*if\s*exists(\([''"]\)syntax_on\1)\n\s*syn\%[tax]\s*reset\n\s*endif'
84+
if !search(pat, 'cnW')
85+
let err['init'] = 'No initialization'
86+
endif
87+
88+
" 6) Does not use :syn on
89+
if search('syn\%[tax]\s\+on', 'cnW')
90+
let err['background'] = 'Should not issue :syn on'
91+
endif
92+
93+
" 7) Does not define filetype specfic groups like vimCommand, htmlTag,
94+
let hi_groups = ['vim', 'html', 'python', 'sh', 'ruby']
95+
for group in hi_groups
96+
let pat='\Chi\%[ghlight]\s*\zs'.group.'\w\+\>'
97+
if search(pat, 'cnW')
98+
let line = search(pat, 'cW')
99+
let err['filetype'] = get(err, 'filetype', 'Should not define: ') . matchstr(getline('.'), pat). ' '
100+
endif
101+
call cursor(1,1)
102+
endfor
103+
let g:err = err
104+
105+
" print Result
106+
call Result(err)
107+
endfu
108+
109+
fu! Result(err)
110+
let do_roups = 0
111+
echohl Title|echomsg "---------------"|echohl Normal
112+
for key in sort(keys(a:err))
113+
if key is# 'highlight'
114+
let do_groups = 1
115+
continue
116+
else
117+
if a:err[key] !~ 'OK'
118+
echohl Title
119+
endif
120+
echomsg printf("%15s: %s", key, a:err[key])
121+
echohl Normal
122+
endif
123+
endfor
124+
echohl Title|echomsg "---------------"|echohl Normal
125+
if do_groups
126+
echohl Title | echomsg "Groups" | echohl Normal
127+
for v1 in sort(keys(a:err['highlight']))
128+
echomsg printf("%25s: %s", v1, a:err['highlight'][v1])
129+
endfor
130+
endif
131+
endfu
132+
133+
call Test_check_colors()
134+
135+
let &cpo = s:save_cpo
136+
unlet s:save_cpo

runtime/doc/autocmd.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ Name triggered by ~
330330

331331
|TextChanged| after a change was made to the text in Normal mode
332332
|TextChangedI| after a change was made to the text in Insert mode
333+
|TextYankPost| after text is yanked or deleted
333334

334335
|ColorScheme| after loading a color scheme
335336

@@ -956,6 +957,26 @@ TextChangedI After a change was made to the text in the
956957
current buffer in Insert mode.
957958
Not triggered when the popup menu is visible.
958959
Otherwise the same as TextChanged.
960+
|TextYankPost|
961+
TextYankPost After text has been yanked or deleted in the
962+
current buffer. The following values of
963+
|v:event| can be used to determine the operation
964+
that triggered this autocmd:
965+
operator The operation performed.
966+
regcontents Text that was stored in the
967+
register, as a list of lines,
968+
like with: >
969+
getreg(r, 1, 1)
970+
< regname Name of the |register| or
971+
empty string for the unnamed
972+
register.
973+
regtype Type of the register, see
974+
|getregtype()|.
975+
Not triggered when |quote_| is used nor when
976+
called recursively.
977+
It is not allowed to change the buffer text,
978+
see |textlock|.
979+
959980
*User*
960981
User Never executed automatically. To be used for
961982
autocommands that are only executed with

runtime/doc/eval.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,6 +1554,12 @@ v:errors Errors found by assert functions, such as |assert_true()|.
15541554
< If v:errors is set to anything but a list it is made an empty
15551555
list by the assert function.
15561556

1557+
*v:event* *event-variable*
1558+
v:event Dictionary containing information about the current
1559+
|autocommand|. The dictionary is emptied when the |autocommand|
1560+
finishes, please refer to |dict-identity| for how to get an
1561+
independent copy of it.
1562+
15571563
*v:exception* *exception-variable*
15581564
v:exception The value of the exception most recently caught and not
15591565
finished. See also |v:throwpoint| and |throw-variables|.

src/auto/configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7598,7 +7598,7 @@ $as_echo "defaulting to no" >&6; }
75987598
$as_echo "no" >&6; }
75997599
fi
76007600
fi
7601-
if test "$enable_terminal" = "yes"; then
7601+
if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
76027602
$as_echo "#define FEAT_TERMINAL 1" >>confdefs.h
76037603

76047604
TERM_SRC="libvterm/src/encoding.c libvterm/src/keyboard.c libvterm/src/mouse.c libvterm/src/parser.c libvterm/src/pen.c libvterm/src/screen.c libvterm/src/state.c libvterm/src/unicode.c libvterm/src/vterm.c"

src/configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2123,7 +2123,7 @@ else
21232123
AC_MSG_RESULT(no)
21242124
fi
21252125
fi
2126-
if test "$enable_terminal" = "yes"; then
2126+
if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then
21272127
AC_DEFINE(FEAT_TERMINAL)
21282128
TERM_SRC="libvterm/src/encoding.c libvterm/src/keyboard.c libvterm/src/mouse.c libvterm/src/parser.c libvterm/src/pen.c libvterm/src/screen.c libvterm/src/state.c libvterm/src/unicode.c libvterm/src/vterm.c"
21292129
AC_SUBST(TERM_SRC)

src/dict.c

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,29 @@ dict_alloc(void)
4747
return d;
4848
}
4949

50+
dict_T *
51+
dict_alloc_lock(int lock)
52+
{
53+
dict_T *d = dict_alloc();
54+
55+
if (d != NULL)
56+
d->dv_lock = lock;
57+
return d;
58+
}
59+
5060
/*
5161
* Allocate an empty dict for a return value.
5262
* Returns OK or FAIL.
5363
*/
5464
int
5565
rettv_dict_alloc(typval_T *rettv)
5666
{
57-
dict_T *d = dict_alloc();
67+
dict_T *d = dict_alloc_lock(0);
5868

5969
if (d == NULL)
6070
return FAIL;
6171

6272
rettv_dict_set(rettv, d);
63-
rettv->v_lock = 0;
6473
return OK;
6574
}
6675

@@ -80,7 +89,7 @@ rettv_dict_set(typval_T *rettv, dict_T *d)
8089
* Free a Dictionary, including all non-container items it contains.
8190
* Ignores the reference count.
8291
*/
83-
static void
92+
void
8493
dict_free_contents(dict_T *d)
8594
{
8695
int todo;
@@ -102,6 +111,8 @@ dict_free_contents(dict_T *d)
102111
--todo;
103112
}
104113
}
114+
115+
/* The hashtab is still locked, it has to be re-initialized anyway */
105116
hash_clear(&d->dv_hashtab);
106117
}
107118

@@ -846,4 +857,23 @@ dict_list(typval_T *argvars, typval_T *rettv, int what)
846857
}
847858
}
848859

860+
/*
861+
* Make each item in the dict readonly (not the value of the item).
862+
*/
863+
void
864+
dict_set_items_ro(dict_T *di)
865+
{
866+
int todo = (int)di->dv_hashtab.ht_used;
867+
hashitem_T *hi;
868+
869+
/* Set readonly */
870+
for (hi = di->dv_hashtab.ht_array; todo > 0 ; ++hi)
871+
{
872+
if (HASHITEM_EMPTY(hi))
873+
continue;
874+
--todo;
875+
HI2DI(hi)->di_flags |= DI_FLAGS_RO | DI_FLAGS_FIX;
876+
}
877+
}
878+
849879
#endif /* defined(FEAT_EVAL) */

src/eval.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ static struct vimvar
192192
{VV_NAME("termu7resp", VAR_STRING), VV_RO},
193193
{VV_NAME("termstyleresp", VAR_STRING), VV_RO},
194194
{VV_NAME("termblinkresp", VAR_STRING), VV_RO},
195+
{VV_NAME("event", VAR_DICT), VV_RO},
195196
};
196197

197198
/* shorthand */
@@ -319,8 +320,9 @@ eval_init(void)
319320

320321
set_vim_var_nr(VV_SEARCHFORWARD, 1L);
321322
set_vim_var_nr(VV_HLSEARCH, 1L);
322-
set_vim_var_dict(VV_COMPLETED_ITEM, dict_alloc());
323+
set_vim_var_dict(VV_COMPLETED_ITEM, dict_alloc_lock(VAR_FIXED));
323324
set_vim_var_list(VV_ERRORS, list_alloc());
325+
set_vim_var_dict(VV_EVENT, dict_alloc_lock(VAR_FIXED));
324326

325327
set_vim_var_nr(VV_FALSE, VVAL_FALSE);
326328
set_vim_var_nr(VV_TRUE, VVAL_TRUE);
@@ -6632,6 +6634,16 @@ get_vim_var_list(int idx)
66326634
return vimvars[idx].vv_list;
66336635
}
66346636

6637+
/*
6638+
* Get Dict v: variable value. Caller must take care of reference count when
6639+
* needed.
6640+
*/
6641+
dict_T *
6642+
get_vim_var_dict(int idx)
6643+
{
6644+
return vimvars[idx].vv_dict;
6645+
}
6646+
66356647
/*
66366648
* Set v:char to character "c".
66376649
*/
@@ -6706,25 +6718,13 @@ set_vim_var_list(int idx, list_T *val)
67066718
void
67076719
set_vim_var_dict(int idx, dict_T *val)
67086720
{
6709-
int todo;
6710-
hashitem_T *hi;
6711-
67126721
clear_tv(&vimvars[idx].vv_di.di_tv);
67136722
vimvars[idx].vv_type = VAR_DICT;
67146723
vimvars[idx].vv_dict = val;
67156724
if (val != NULL)
67166725
{
67176726
++val->dv_refcount;
6718-
6719-
/* Set readonly */
6720-
todo = (int)val->dv_hashtab.ht_used;
6721-
for (hi = val->dv_hashtab.ht_array; todo > 0 ; ++hi)
6722-
{
6723-
if (HASHITEM_EMPTY(hi))
6724-
continue;
6725-
--todo;
6726-
HI2DI(hi)->di_flags |= DI_FLAGS_RO | DI_FLAGS_FIX;
6727-
}
6727+
dict_set_items_ro(val);
67286728
}
67296729
}
67306730

src/ex_getln.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,22 @@ abandon_cmdline(void)
172172
redraw_cmdline = TRUE;
173173
}
174174

175+
/*
176+
* Guess that the pattern matches everything. Only finds specific cases, such
177+
* as a trailing \|, which can happen while typing a pattern.
178+
*/
179+
static int
180+
empty_pattern(char_u *p)
181+
{
182+
int n = STRLEN(p);
183+
184+
/* remove trailing \v and the like */
185+
while (n >= 2 && p[n - 2] == '\\'
186+
&& vim_strchr((char_u *)"mMvVcCZ", p[n - 1]) != NULL)
187+
n -= 2;
188+
return n == 0 || (n >= 2 && p[n - 2] == '\\' && p[n - 1] == '|');
189+
}
190+
175191
/*
176192
* getcmdline() - accept a command line starting with firstc.
177193
*
@@ -1802,11 +1818,11 @@ getcmdline(
18021818
# endif
18031819
old_botline = curwin->w_botline;
18041820
update_screen(NOT_VALID);
1805-
restore_last_search_pattern();
18061821
redrawcmdline();
18071822
}
18081823
else
18091824
vim_beep(BO_ERROR);
1825+
restore_last_search_pattern();
18101826
goto cmdline_not_changed;
18111827
}
18121828
break;
@@ -2031,6 +2047,11 @@ getcmdline(
20312047
else
20322048
end_pos = curwin->w_cursor; /* shutup gcc 4 */
20332049

2050+
/* Disable 'hlsearch' highlighting if the pattern matches
2051+
* everything. Avoids a flash when typing "foo\|". */
2052+
if (empty_pattern(ccline.cmdbuff))
2053+
SET_NO_HLSEARCH(TRUE);
2054+
20342055
validate_cursor();
20352056
/* May redraw the status line to show the cursor position. */
20362057
if (p_ru && curwin->w_status_height > 0)

0 commit comments

Comments
 (0)