From 2bde381d28ccad65267afb88d3ab0e09aedbb912 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 27 Jan 2021 00:33:42 -0500 Subject: vim-patch:8.2.2412: not all fields in "cstack" are initialized Problem: Not all fields in "cstack" are initialized which might cause a crash. Solution: Use CLEAR_FIELD(). https://github.com/vim/vim/commit/ce0370d9e67df80c62ff033aa8ca2dbe86841de9 --- src/nvim/ex_docmd.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 18683c54d3..8b00417ce3 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -317,7 +317,9 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, int count = 0; /* line number count */ int did_inc = FALSE; /* incremented RedrawingDisabled */ int retval = OK; - cstack_T cstack; // conditional stack + cstack_T cstack = { // conditional stack + .cs_idx = -1, + }; garray_T lines_ga; // keep lines for ":while"/":for" int current_line = 0; // active line in lines_ga char_u *fname = NULL; // function or script name @@ -360,11 +362,6 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, call_depth++; start_batch_changes(); - cstack.cs_idx = -1; - cstack.cs_looplevel = 0; - cstack.cs_trylevel = 0; - cstack.cs_emsg_silent_list = NULL; - cstack.cs_lflags = 0; ga_init(&lines_ga, (int)sizeof(wcmd_T), 10); real_cookie = getline_cookie(fgetline, cookie); -- cgit From f05ffaef1c184986e653739f7844a592f781483b Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 28 Jan 2021 23:03:15 -0500 Subject: vim-patch:8.2.2418: color not changed if ModeMsg highlight is set in InsertEnter Problem: Color not changed if ModeMsg highlight is set in InsertEnter autocmd event. (Paul Swanson) Solution: Call highlight_changed() after triggering InsertEnter. (closes vim/vim#7751) https://github.com/vim/vim/commit/2e6cdb91e8dea08301f31bc83188c06112eb7f57 --- src/nvim/edit.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/nvim/edit.c b/src/nvim/edit.c index b2abb06075..100e88e261 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -313,6 +313,11 @@ static void insert_enter(InsertState *s) set_vim_var_string(VV_CHAR, NULL, -1); ins_apply_autocmds(EVENT_INSERTENTER); + // Check for changed highlighting, e.g. for ModeMsg. + if (need_highlight_changed) { + highlight_changed(); + } + // Make sure the cursor didn't move. Do call check_cursor_col() in // case the text was modified. Since Insert mode was not started yet // a call to check_cursor_col() may move the cursor, especially with -- cgit From c77b679ecd142f42a307ce1d5a1974f9bbb47911 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 28 Jan 2021 23:06:30 -0500 Subject: vim-patch:8.2.2420: too many problems with using all autocommand events Problem: Too many problems with using all autocommand events. Solution: Disallow defining an autocommand for all events. https://github.com/vim/vim/commit/9a046fd08bcae319d39a4dbde2be81decee19013 Delete Test_wipe_cbuffer(). Commit dc5f4a3cc2f7f02e1ff4ec2f67eda4fb73e7d89c should have removed it. --- src/nvim/autocmd.c | 14 +++++++++----- src/nvim/globals.h | 2 ++ src/nvim/testdir/test_autocmd.vim | 23 +++-------------------- src/nvim/testdir/test_quickfix.vim | 12 ++++++------ src/nvim/testdir/test_window_cmd.vim | 4 ++-- 5 files changed, 22 insertions(+), 33 deletions(-) diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index 42224d0a4f..140a9c6bcb 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -700,11 +700,15 @@ void do_autocmd(char_u *arg_in, int forceit) last_event = (event_T)-1; // for listing the event name last_group = AUGROUP_ERROR; // for listing the group name if (*arg == '*' || *arg == NUL || *arg == '|') { - for (event_T event = (event_T)0; event < (int)NUM_EVENTS; - event = (event_T)(event + 1)) { - if (do_autocmd_event(event, pat, once, nested, cmd, forceit, group) - == FAIL) { - break; + if (!forceit && *cmd != NUL) { + EMSG(_(e_cannot_define_autocommands_for_all_events)); + } else { + for (event_T event = (event_T)0; event < (int)NUM_EVENTS; + event = (event_T)(event + 1)) { + if (do_autocmd_event(event, pat, once, nested, cmd, forceit, group) + == FAIL) { + break; + } } } } else { diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 3b8f4116b7..22f06941aa 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -1009,6 +1009,8 @@ EXTERN char_u e_floatonly[] INIT(=N_( EXTERN char_u e_floatexchange[] INIT(=N_( "E5602: Cannot exchange or rotate float")); +EXTERN char e_cannot_define_autocommands_for_all_events[] INIT(= N_( + "E1155: Cannot define autocommands for ALL events")); EXTERN char top_bot_msg[] INIT(= N_("search hit TOP, continuing at BOTTOM")); EXTERN char bot_top_msg[] INIT(= N_("search hit BOTTOM, continuing at TOP")); diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index c571e37ac3..374ad65aa9 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -1279,26 +1279,9 @@ func Test_TextYankPost() bwipe! endfunc -func Test_nocatch_wipe_all_buffers() - " Real nasty autocommand: wipe all buffers on any event. - au * * bwipe * - call assert_fails('next x', 'E93') - bwipe - au! -endfunc - -func Test_nocatch_wipe_dummy_buffer() - " Nasty autocommand: wipe buffer on any event. - au * x bwipe - call assert_fails('lv½ /x', 'E480') - au! -endfunc - -func Test_wipe_cbuffer() - sv x - au * * bw - lb - au! +func Test_autocommand_all_events() + call assert_fails('au * * bwipe', 'E1155:') + call assert_fails('au * x bwipe', 'E1155:') endfunc " Test TextChangedI and TextChangedP diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 48c0a83053..00a253a215 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -3540,7 +3540,7 @@ func Test_lbuffer_crash() sv Xtest augroup QF_Test au! - au * * bw + au QuickFixCmdPre,QuickFixCmdPost,BufEnter,BufLeave * bw augroup END lbuffer augroup QF_Test @@ -3552,7 +3552,7 @@ endfunc func Test_lexpr_crash() augroup QF_Test au! - au * * call setloclist(0, [], 'f') + au QuickFixCmdPre,QuickFixCmdPost,BufEnter,BufLeave * call setloclist(0, [], 'f') augroup END lexpr "" augroup QF_Test @@ -3587,7 +3587,7 @@ func Test_lvimgrep_crash() sv Xtest augroup QF_Test au! - au * * call setloclist(0, [], 'f') + au QuickFixCmdPre,QuickFixCmdPost,BufEnter,BufLeave * call setloclist(0, [], 'f') augroup END lvimgrep quickfix test_quickfix.vim augroup QF_Test @@ -3889,7 +3889,7 @@ func Test_lbuffer_with_bwipe() new new augroup nasty - au * * bwipe + au QuickFixCmdPre,QuickFixCmdPost,BufEnter,BufLeave * bwipe augroup END lbuffer augroup nasty @@ -3902,9 +3902,9 @@ endfunc func Xexpr_acmd_freelist(cchar) call s:setup_commands(a:cchar) - " This was using freed memory. + " This was using freed memory (but with what events?) augroup nasty - au * * call g:Xsetlist([], 'f') + au QuickFixCmdPre,QuickFixCmdPost,BufEnter,BufLeave * call g:Xsetlist([], 'f') augroup END Xexpr "x" augroup nasty diff --git a/src/nvim/testdir/test_window_cmd.vim b/src/nvim/testdir/test_window_cmd.vim index 687b1cb989..969b75d424 100644 --- a/src/nvim/testdir/test_window_cmd.vim +++ b/src/nvim/testdir/test_window_cmd.vim @@ -513,8 +513,8 @@ func Test_window_colon_command() endfunc func Test_access_freed_mem() - " This was accessing freed memory - au * 0 vs xxx + " This was accessing freed memory (but with what events?) + au BufEnter,BufLeave,WinEnter,WinLeave 0 vs xxx arg 0 argadd all -- cgit From 1376994f1556b51d6a4feaedc094ee2456db5d06 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 28 Jan 2021 23:48:52 -0500 Subject: vim-patch:8.2.2425: cursor on invalid line with range and :substitute Problem: Cursor on invalid line with range and :substitute. Solution: Do not move the cursor when skipping commands. (closes vim/vim#3434) https://github.com/vim/vim/commit/df2c2988bbaecd28b0fbec8d64327b1bbb005e19 Cherry-pick Test_for_invalid() from patch v8.1.0736. --- src/nvim/ex_cmds.c | 3 +++ src/nvim/testdir/test_eval_stuff.vim | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index a2487336f1..2da8c205c1 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -3126,6 +3126,9 @@ static bool sub_joining_lines(exarg_T *eap, char_u *pat, char_u *sub, || *cmd == 'l' || *cmd == 'p' || *cmd == '#')))) { + if (eap->skip) { + return true; + } curwin->w_cursor.lnum = eap->line1; if (*cmd == 'l') { eap->flags = EXFLAG_LIST; diff --git a/src/nvim/testdir/test_eval_stuff.vim b/src/nvim/testdir/test_eval_stuff.vim index 061364fb73..ff50d53d86 100644 --- a/src/nvim/testdir/test_eval_stuff.vim +++ b/src/nvim/testdir/test_eval_stuff.vim @@ -22,6 +22,17 @@ func Test_E963() call assert_equal(v_o, v:oldfiles) endfunc +func Test_for_invalid() + call assert_fails("for x in 99", 'E714:') + call assert_fails("for x in 'asdf'", 'E714:') + call assert_fails("for x in {'a': 9}", 'E714:') + + if 0 + /1/5/2/s/\n + endif + redraw +endfunc + func Test_mkdir_p() call mkdir('Xmkdir/nested', 'p') call assert_true(isdirectory('Xmkdir/nested')) -- cgit