From ea03032018c39b9976b664071ebcd1a75463348c Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 14 Sep 2020 01:17:47 -0400 Subject: vim-patch:8.1.2338: using Visual mark sith :s gives E20 if not set Problem: Using Visual mark sith :s gives E20 if not set. Solution: Ignore errors when handling 'incsearch'. (closes vim/vim#3837) https://github.com/vim/vim/commit/c672525b487992306f69ceab093291ba3b8e4246 N/A patches for version.c: vim-patch:8.2.1526: line in testdir Makefile got commented out Problem: Line in testdir Makefile got commented out. (Christian Brabandt) Solution: Revert. https://github.com/vim/vim/commit/228e62975e7aef9d6224a5a7c43625c1c1494fc2 vim-patch:8.2.1675: MinGW: testdir makefile deletes non-existing file Problem: MinGW: testdir makefile deletes non-existing file. Solution: Use another way to delete the output file if it already exists. (Michael Soyka) https://github.com/vim/vim/commit/05c1acd5e1564ea4dbc7d4be26908af6909f43f6 --- src/nvim/ex_getln.c | 21 +++++++++++++-------- src/nvim/testdir/test_search.vim | 13 +++++++++++++ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 8f2d536e63..d57239e570 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -288,6 +288,7 @@ static bool do_incsearch_highlighting(int firstc, incsearch_state_T *s, exarg_T ea; pos_T save_cursor; bool use_last_pat; + bool retval = false; *skiplen = 0; *patlen = ccline.cmdlen; @@ -307,6 +308,7 @@ static bool do_incsearch_highlighting(int firstc, incsearch_state_T *s, return false; } + emsg_off++; memset(&ea, 0, sizeof(ea)); ea.line1 = 1; ea.line2 = 1; @@ -318,13 +320,13 @@ static bool do_incsearch_highlighting(int firstc, incsearch_state_T *s, cmd = skip_range(ea.cmd, NULL); if (vim_strchr((char_u *)"sgvl", *cmd) == NULL) { - return false; + goto theend; } // Skip over "substitute" to find the pattern separator. for (p = cmd; ASCII_ISALPHA(*p); p++) {} if (*skipwhite(p) == NUL) { - return false; + goto theend; } if (STRNCMP(cmd, "substitute", p - cmd) == 0 @@ -342,7 +344,7 @@ static bool do_incsearch_highlighting(int firstc, incsearch_state_T *s, p++; } if (*p == NUL) { - return false; + goto theend; } } else if (STRNCMP(cmd, "vimgrep", MAX(p - cmd, 3)) == 0 || STRNCMP(cmd, "vimgrepadd", MAX(p - cmd, 8)) == 0 @@ -353,14 +355,14 @@ static bool do_incsearch_highlighting(int firstc, incsearch_state_T *s, if (*p == '!') { p++; if (*skipwhite(p) == NUL) { - return false; + goto theend; } } if (*cmd != 'g') { delim_optional = true; } } else { - return false; + goto theend; } p = skipwhite(p); @@ -369,7 +371,7 @@ static bool do_incsearch_highlighting(int firstc, incsearch_state_T *s, use_last_pat = end == p && *end == delim; if (end == p && !use_last_pat) { - return false; + goto theend; } // Don't do 'hlsearch' highlighting if the pattern matches everything. @@ -381,7 +383,7 @@ static bool do_incsearch_highlighting(int firstc, incsearch_state_T *s, empty = empty_pattern(p); *end = c; if (empty) { - return false; + goto theend; } } @@ -409,7 +411,10 @@ static bool do_incsearch_highlighting(int firstc, incsearch_state_T *s, } curwin->w_cursor = save_cursor; - return true; + retval = true; +theend: + emsg_off--; + return retval; } // May do 'incsearch' highlighting if desired. diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index e3a0fce5a6..aaa60e39c9 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -708,6 +708,19 @@ func Test_incsearch_substitute_dump() call VerifyScreenDump(buf, 'Test_incsearch_substitute_12', {}) call term_sendkeys(buf, "\") call VerifyScreenDump(buf, 'Test_incsearch_substitute_13', {}) + call term_sendkeys(buf, ":%bwipe!\") + call term_sendkeys(buf, ":only!\") + + " get :'<,'>s command in history + call term_sendkeys(buf, ":set cmdheight=2\") + call term_sendkeys(buf, "aasdfasdf\") + call term_sendkeys(buf, "V:s/a/b/g\") + " Using '<,'> does not give E20 + call term_sendkeys(buf, ":new\") + call term_sendkeys(buf, "aasdfasdf\") + call term_sendkeys(buf, ":\\") + call VerifyScreenDump(buf, 'Test_incsearch_substitute_14', {}) + call term_sendkeys(buf, "") call StopVimInTerminal(buf) call delete('Xis_subst_script') -- cgit From cc484928d5b3402e0d93318df5b7b9b3385f2ee5 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 14 Sep 2020 01:30:49 -0400 Subject: vim-patch:8.2.0637: incsearch highlighting does not work for ":sort!" Problem: Incsearch highlighting does not work for ":sort!". Solution: Skip over the exclamation point. (closes vim/vim#5983) https://github.com/vim/vim/commit/333015a46e916f566763ec44ae8669c0378767d9 --- src/nvim/ex_getln.c | 5 ++++- src/nvim/testdir/test_search.vim | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index d57239e570..996ccc8e60 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -339,7 +339,10 @@ static bool do_incsearch_highlighting(int firstc, incsearch_state_T *s, p_magic = false; } } else if (STRNCMP(cmd, "sort", MAX(p - cmd, 3)) == 0) { - // skip over flags. + // skip over ! and flags + if (*p == '!') { + p = skipwhite(p + 1); + } while (ASCII_ISALPHA(*(p = skipwhite(p)))) { p++; } diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index aaa60e39c9..211fc73562 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -743,11 +743,14 @@ func Test_incsearch_sort_dump() " the 'ambiwidth' check. sleep 100m - " Need to send one key at a time to force a redraw. call term_sendkeys(buf, ':sort ni u /on') call VerifyScreenDump(buf, 'Test_incsearch_sort_01', {}) call term_sendkeys(buf, "\") + call term_sendkeys(buf, ':sort! /on') + call VerifyScreenDump(buf, 'Test_incsearch_sort_02', {}) + call term_sendkeys(buf, "\") + call StopVimInTerminal(buf) call delete('Xis_sort_script') endfunc -- cgit From eb981a01e3d389017378da0586d2895865ec9a7d Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 14 Sep 2020 18:24:02 -0400 Subject: vim-patch:8.2.1684: "gF" does not use line number after file in Visual mode Problem: "gF" does not use line number after file in Visual mode. Solution: Look for ":123" after the Visual area. (closes vim/vim#6952) https://github.com/vim/vim/commit/efd5d8a967ba80f9e2826c35be98344d8f00af77 Cherry-pick test_gf_visual changes from patch 8.2.1040. --- src/nvim/testdir/test_gf.vim | 27 ++++++++++++++++++++++++++- src/nvim/window.c | 6 ++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/nvim/testdir/test_gf.vim b/src/nvim/testdir/test_gf.vim index 4a4ffcefa1..ee548037ba 100644 --- a/src/nvim/testdir/test_gf.vim +++ b/src/nvim/testdir/test_gf.vim @@ -1,3 +1,4 @@ +" Test for the gf and gF (goto file) commands " This is a test if a URL is recognized by "gf", with the cursor before and " after the "://". Also test ":\\". @@ -109,7 +110,7 @@ func Test_gf() endfunc func Test_gf_visual() - call writefile([], "Xtest_gf_visual") + call writefile(['one', 'two', 'three', 'four'], "Xtest_gf_visual") new call setline(1, 'XXXtest_gf_visualXXX') set hidden @@ -118,6 +119,30 @@ func Test_gf_visual() norm! ttvtXgf call assert_equal('Xtest_gf_visual', bufname('%')) + " if multiple lines are selected, then gf should fail + call setline(1, ["one", "two"]) + normal VGgf + call assert_equal('Xtest_gf_visual', @%) + + " following line number is used for gF + bwipe! + new + call setline(1, 'XXXtest_gf_visual:3XXX') + norm! 0ttvt:gF + call assert_equal('Xtest_gf_visual', bufname('%')) + call assert_equal(3, getcurpos()[1]) + + " line number in visual area is used for file name + if has('unix') + bwipe! + call writefile([], "Xtest_gf_visual:3") + new + call setline(1, 'XXXtest_gf_visual:3XXX') + norm! 0ttvtXgF + call assert_equal('Xtest_gf_visual:3', bufname('%')) + call delete('Xtest_gf_visual:3') + endif + bwipe! call delete('Xtest_gf_visual') set hidden& diff --git a/src/nvim/window.c b/src/nvim/window.c index cec0dfd67f..6608deb231 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -6019,6 +6019,12 @@ char_u *grab_file_name(long count, linenr_T *file_lnum) char_u *ptr; if (get_visual_text(NULL, &ptr, &len) == FAIL) return NULL; + // Only recognize ":123" here + if (file_lnum != NULL && ptr[len] == ':' && isdigit(ptr[len + 1])) { + char_u *p = ptr + len + 1; + + *file_lnum = getdigits_long(&p, false, 0); + } return find_file_name_in_path(ptr, len, options, count, curbuf->b_ffname); } return file_name_at_cursor(options | FNAME_HYP, count, file_lnum); -- cgit From ba16475549d4e9c8c0a0f1d28cfb3e4e5b3c1108 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 15 Sep 2020 01:49:54 -0400 Subject: vim-patch:8.1.2108: cannot close the cmdline window from CmdWinEnter Problem: Cannot close the cmdline window from CmdWinEnter. (George Brown) Solution: Reset cmdwin_result earlier. (Christian Brabandt, closes vim/vim#4980) https://github.com/vim/vim/commit/23324a0b35d18c5caac20b1d543ed2d1f762f5b5 --- src/nvim/ex_getln.c | 6 ++++-- src/nvim/testdir/test_autocmd.vim | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 996ccc8e60..fb305f927a 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -6471,12 +6471,15 @@ static int open_cmdwin(void) // Save the command line info, can be used recursively. save_cmdline(&save_ccline); - /* No Ex mode here! */ + // No Ex mode here! exmode_active = 0; State = NORMAL; setmouse(); + // Reset here so it can be set by a CmdWinEnter autocommand. + cmdwin_result = 0; + // Trigger CmdwinEnter autocommands. typestr[0] = (char_u)cmdwin_type; typestr[1] = NUL; @@ -6492,7 +6495,6 @@ static int open_cmdwin(void) /* * Call the main loop until or CTRL-C is typed. */ - cmdwin_result = 0; normal_enter(true, false); RedrawingDisabled = i; diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 3dd68873d4..094bb3ebd1 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -1,6 +1,8 @@ " Tests for autocommands source shared.vim +source check.vim +source term_util.vim func! s:cleanup_buffers() abort for bnr in range(1, bufnr('$')) @@ -1735,6 +1737,35 @@ func Test_throw_in_BufWritePre() au! throwing endfunc +func Test_autocmd_CmdWinEnter() + CheckRunVimInTerminal + " There is not cmdwin switch, so + " test for cmdline_hist + " (both are available with small builds) + CheckFeature cmdline_hist + let lines =<< trim END + let b:dummy_var = 'This is a dummy' + autocmd CmdWinEnter * quit + let winnr = winnr('$') + END + let filename='XCmdWinEnter' + call writefile(lines, filename) + let buf = RunVimInTerminal('-S '.filename, #{rows: 6}) + + call term_sendkeys(buf, "q:") + call term_wait(buf) + call term_sendkeys(buf, ":echo b:dummy_var\") + call WaitForAssert({-> assert_match('^This is a dummy', term_getline(buf, 6))}, 1000) + call term_sendkeys(buf, ":echo &buftype\") + call WaitForAssert({-> assert_notmatch('^nofile', term_getline(buf, 6))}, 1000) + call term_sendkeys(buf, ":echo winnr\") + call WaitForAssert({-> assert_match('^1', term_getline(buf, 6))}, 1000) + + " clean up + call StopVimInTerminal(buf) + call delete(filename) +endfunc + func Test_FileChangedShell_reload() if !has('unix') return -- cgit From 2ed48e71d3a55ee95579df80e46f3fa40639d84a Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 15 Sep 2020 02:03:04 -0400 Subject: vim-patch:8.1.2222: accessing invalid memory Problem: Accessing invalid memory. (Dominique Pelle) Solution: Reset highlight_match every time. (closes vim/vim#5125) https://github.com/vim/vim/commit/7ab5d77666c98f5229759402a451a26ea57a4801 --- src/nvim/ex_getln.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index fb305f927a..f9ca7bfa42 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -557,6 +557,7 @@ static void may_do_incsearch_highlighting(int firstc, long count, } update_screen(SOME_VALID); + highlight_match = false; restore_last_search_pattern(); // Leave it at the end to make CTRL-R CTRL-W work. But not when beyond the @@ -1549,6 +1550,7 @@ static int may_do_command_line_next_incsearch(int firstc, long count, highlight_match = true; save_viewstate(&s->old_viewstate); update_screen(NOT_VALID); + highlight_match = false; redrawcmdline(); curwin->w_cursor = s->match_end; } else { -- cgit