From 94c743348eda14fd08290e646c6a8f50ff217dc0 Mon Sep 17 00:00:00 2001 From: Paper Date: Mon, 28 Sep 2020 12:20:41 +0200 Subject: [PATCH 01/10] runtime: backport IPv6 support to resolv.vim from commits bc93cebb692f47488d66f078d1728031e9be35e7 and b17893aa940dc7d45421f875f5d90855880aad27 from vim --- runtime/syntax/resolv.vim | 53 ++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/runtime/syntax/resolv.vim b/runtime/syntax/resolv.vim index a879116a5f..9a2dec51ce 100644 --- a/runtime/syntax/resolv.vim +++ b/runtime/syntax/resolv.vim @@ -2,12 +2,19 @@ " Language: resolver configuration file " Maintainer: Radu Dineiu " URL: https://raw.github.com/rid9/vim-resolv/master/resolv.vim -" Last Change: 2013 May 21 -" Version: 1.0 +" Last Change: 2020 Mar 10 +" Version: 1.4 " " Credits: " David Necas (Yeti) " Stefano Zacchiroli +" DJ Lucas +" +" Changelog: +" - 1.4: Added IPv6 support for sortlist. +" - 1.3: Added IPv6 support for IPv4 dot-decimal notation. +" - 1.2: Added new options. +" - 1.1: Added IPv6 support. " quit when a syntax file was already loaded if exists("b:current_syntax") @@ -29,11 +36,47 @@ syn match resolvIP contained /\%(\d\{1,4}\.\)\{3}\d\{1,4}/ contains=@resolvIPClu syn match resolvIPNetmask contained /\%(\d\{1,4}\.\)\{3}\d\{1,4}\%(\/\%(\%(\d\{1,4}\.\)\{,3}\d\{1,4}\)\)\?/ contains=resolvOperator,@resolvIPCluster syn match resolvHostname contained /\w\{-}\.[-0-9A-Za-z_\.]*/ -" Particular +" Nameserver IPv4 syn match resolvIPNameserver contained /\%(\%(\d\{1,4}\.\)\{3}\d\{1,4}\%(\s\|$\)\)\+/ contains=@resolvIPCluster + +" Nameserver IPv6 +syn match resolvIPNameserver contained /\<\%(\x\{1,4}:\)\{6}\%(\x\{1,4}:\x\{1,4}\)\>/ +syn match resolvIPNameserver contained /\s\@<=::\%(\x\{1,4}:\)\{,6}\x\{1,4}\>/ +syn match resolvIPNameserver contained /\s\@<=::\%(\x\{1,4}:\)\{,5}\%(\d\{1,4}\.\)\{3}\d\{1,4}\>/ +syn match resolvIPNameserver contained /\<\%(\x\{1,4}:\)\{1}:\%(\x\{1,4}:\)\{,5}\x\{1,4}\>/ +syn match resolvIPNameserver contained /\<\%(\x\{1,4}:\)\{1}:\%(\x\{1,4}:\)\{,4}\%(\d\{1,4}\.\)\{3}\d\{1,4}\>/ +syn match resolvIPNameserver contained /\<\%(\x\{1,4}:\)\{2}:\%(\x\{1,4}:\)\{,4}\x\{1,4}\>/ +syn match resolvIPNameserver contained /\<\%(\x\{1,4}:\)\{2}:\%(\x\{1,4}:\)\{,3}\%(\d\{1,4}\.\)\{3}\d\{1,4}\>/ +syn match resolvIPNameserver contained /\<\%(\x\{1,4}:\)\{3}:\%(\x\{1,4}:\)\{,3}\x\{1,4}\>/ +syn match resolvIPNameserver contained /\<\%(\x\{1,4}:\)\{3}:\%(\x\{1,4}:\)\{,2}\%(\d\{1,4}\.\)\{3}\d\{1,4}\>/ +syn match resolvIPNameserver contained /\<\%(\x\{1,4}:\)\{4}:\%(\x\{1,4}:\)\{,2}\x\{1,4}\>/ +syn match resolvIPNameserver contained /\<\%(\x\{1,4}:\)\{4}:\%(\x\{1,4}:\)\{,1}\%(\d\{1,4}\.\)\{3}\d\{1,4}\>/ +syn match resolvIPNameserver contained /\<\%(\x\{1,4}:\)\{5}:\%(\d\{1,4}\.\)\{3}\d\{1,4}\>/ +syn match resolvIPNameserver contained /\<\%(\x\{1,4}:\)\{6}:\x\{1,4}\>/ +syn match resolvIPNameserver contained /\<\%(\x\{1,4}:\)\{1,7}:\%(\s\|;\|$\)\@=/ + +" Search hostname syn match resolvHostnameSearch contained /\%(\%([-0-9A-Za-z_]\+\.\)*[-0-9A-Za-z_]\+\.\?\%(\s\|$\)\)\+/ + +" Sortlist IPv4 syn match resolvIPNetmaskSortList contained /\%(\%(\d\{1,4}\.\)\{3}\d\{1,4}\%(\/\%(\%(\d\{1,4}\.\)\{,3}\d\{1,4}\)\)\?\%(\s\|$\)\)\+/ contains=resolvOperator,@resolvIPCluster +" Sortlist IPv6 +syn match resolvIPNetmaskSortList contained /\<\%(\x\{1,4}:\)\{6}\%(\x\{1,4}:\x\{1,4}\)\%(\/\d\{1,3}\)\?\>/ +syn match resolvIPNetmaskSortList contained /\s\@<=::\%(\x\{1,4}:\)\{,6}\x\{1,4}\%(\/\d\{1,3}\)\?\>/ +syn match resolvIPNetmaskSortList contained /\s\@<=::\%(\x\{1,4}:\)\{,5}\%(\d\{1,4}\.\)\{3}\d\{1,4}\%(\/\d\{1,3}\)\?\>/ +syn match resolvIPNetmaskSortList contained /\<\%(\x\{1,4}:\)\{1}:\%(\x\{1,4}:\)\{,5}\x\{1,4}\%(\/\d\{1,3}\)\?\>/ +syn match resolvIPNetmaskSortList contained /\<\%(\x\{1,4}:\)\{1}:\%(\x\{1,4}:\)\{,4}\%(\d\{1,4}\.\)\{3}\d\{1,4}\%(\/\d\{1,3}\)\?\>/ +syn match resolvIPNetmaskSortList contained /\<\%(\x\{1,4}:\)\{2}:\%(\x\{1,4}:\)\{,4}\x\{1,4}\%(\/\d\{1,3}\)\?\>/ +syn match resolvIPNetmaskSortList contained /\<\%(\x\{1,4}:\)\{2}:\%(\x\{1,4}:\)\{,3}\%(\d\{1,4}\.\)\{3}\d\{1,4}\%(\/\d\{1,3}\)\?\>/ +syn match resolvIPNetmaskSortList contained /\<\%(\x\{1,4}:\)\{3}:\%(\x\{1,4}:\)\{,3}\x\{1,4}\%(\/\d\{1,3}\)\?\>/ +syn match resolvIPNetmaskSortList contained /\<\%(\x\{1,4}:\)\{3}:\%(\x\{1,4}:\)\{,2}\%(\d\{1,4}\.\)\{3}\d\{1,4}\%(\/\d\{1,3}\)\?\>/ +syn match resolvIPNetmaskSortList contained /\<\%(\x\{1,4}:\)\{4}:\%(\x\{1,4}:\)\{,2}\x\{1,4}\%(\/\d\{1,3}\)\?\>/ +syn match resolvIPNetmaskSortList contained /\<\%(\x\{1,4}:\)\{4}:\%(\x\{1,4}:\)\{,1}\%(\d\{1,4}\.\)\{3}\d\{1,4}\%(\/\d\{1,3}\)\?\>/ +syn match resolvIPNetmaskSortList contained /\<\%(\x\{1,4}:\)\{5}:\%(\d\{1,4}\.\)\{3}\d\{1,4}\%(\/\d\{1,3}\)\?\>/ +syn match resolvIPNetmaskSortList contained /\<\%(\x\{1,4}:\)\{6}:\x\{1,4}\%(\/\d\{1,3}\)\?\>/ +syn match resolvIPNetmaskSortList contained /\<\%(\x\{1,4}:\)\{1,7}:\%(\s\|;\|$\)\@=\%(\/\d\{1,3}\)\?/ + " Identifiers syn match resolvNameserver /^\s*nameserver\>/ nextgroup=resolvIPNameserver skipwhite syn match resolvLwserver /^\s*lwserver\>/ nextgroup=resolvIPNameserver skipwhite @@ -43,13 +86,12 @@ syn match resolvSortList /^\s*sortlist\>/ nextgroup=resolvIPNetmaskSortList skip syn match resolvOptions /^\s*options\>/ nextgroup=resolvOption skipwhite " Options -syn match resolvOption /\<\%(debug\|no_tld_query\|rotate\|no-check-names\|inet6\)\>/ contained nextgroup=resolvOption skipwhite +syn match resolvOption /\<\%(debug\|no_tld_query\|no-tld-query\|rotate\|no-check-names\|inet6\|ip6-bytestring\|\%(no-\)\?ip6-dotint\|edns0\|single-request\%(-reopen\)\?\|use-vc\)\>/ contained nextgroup=resolvOption skipwhite syn match resolvOption /\<\%(ndots\|timeout\|attempts\):\d\+\>/ contained contains=resolvOperator nextgroup=resolvOption skipwhite " Additional errors syn match resolvError /^search .\{257,}/ - hi def link resolvIP Number hi def link resolvIPNetmask Number hi def link resolvHostname String @@ -72,7 +114,6 @@ hi def link resolvError Error hi def link resolvIPError Error hi def link resolvIPSpecial Special - let b:current_syntax = "resolv" " vim: ts=8 ft=vim From 8154c77bef1327aca76b83a1ec5177510f6b4b7b Mon Sep 17 00:00:00 2001 From: erw7 Date: Thu, 1 Oct 2020 16:53:21 +0900 Subject: [PATCH 02/10] screen.c: fix buffer overflow due to folding fixes #12988. --- src/nvim/screen.c | 10 ++++++++++ test/functional/ui/fold_spec.lua | 24 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/nvim/screen.c b/src/nvim/screen.c index f3fdafcc70..3503348049 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -2822,6 +2822,16 @@ win_line ( n_extra = wp->w_p_rl ? (col + 1) : (grid->Columns - col); } + if (draw_state == WL_LINE + && foldinfo.fi_level != 0 + && foldinfo.fi_lines > 0 + && col >= grid->Columns + && n_extra != 0 + && row == startrow) { + // Truncate the folding. + n_extra = 0; + } + if (draw_state == WL_LINE && (area_highlighting || has_spell)) { // handle Visual or match highlighting in this line if (vcol == fromcol diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index fe67b9f6b0..9877f30206 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -6,6 +6,8 @@ local feed_command = helpers.feed_command local insert = helpers.insert local funcs = helpers.funcs local meths = helpers.meths +local source = helpers.source +local assert_alive = helpers.assert_alive describe("folded lines", function() local screen @@ -357,4 +359,26 @@ describe("folded lines", function() | ]]} end) + + it('does not crash when foldtext is longer than columns #12988', function() + source([[ + function! MyFoldText() abort + return repeat('-', &columns + 100) + endfunction + ]]) + command('set foldtext=MyFoldText()') + feed("i") + feed("vkzf") + screen:expect{grid=[[ + {5:^---------------------------------------------}| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + assert_alive() + end) end) From 620c8fdfe91a382982fafaa376acd722fe0df051 Mon Sep 17 00:00:00 2001 From: erw7 Date: Wed, 23 Sep 2020 10:33:18 +0900 Subject: [PATCH 03/10] extmark: fix decoration ploblems with extmark 54ce101 changed the way undo entries are created when adding decorations. This creates all sorts of problems.This change fixes the problem by reverting to the previous behavior. --- src/nvim/api/buffer.c | 4 ++-- src/nvim/extmark.c | 2 +- test/functional/api/highlight_spec.lua | 12 ++++++++++++ test/functional/ui/inccommand_spec.lua | 20 ++++++++++++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index e77870dcf3..2eeaeae522 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -1534,7 +1534,7 @@ Integer nvim_buf_add_highlight(Buffer buffer, ns_id = extmark_set(buf, ns_id, 0, (int)line, (colnr_T)col_start, end_line, (colnr_T)col_end, - decoration_hl(hl_id), kExtmarkUndo); + decoration_hl(hl_id), kExtmarkNoUndo); return src_id; } @@ -1664,7 +1664,7 @@ Integer nvim_buf_set_virtual_text(Buffer buffer, Decoration *decor = xcalloc(1, sizeof(*decor)); decor->virt_text = virt_text; - extmark_set(buf, ns_id, 0, (int)line, 0, -1, -1, decor, kExtmarkUndo); + extmark_set(buf, ns_id, 0, (int)line, 0, -1, -1, decor, kExtmarkNoUndo); return src_id; } diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c index 17141f12fd..0de396fd1f 100644 --- a/src/nvim/extmark.c +++ b/src/nvim/extmark.c @@ -783,7 +783,7 @@ void bufhl_add_hl_pos_offset(buf_T *buf, } (void)extmark_set(buf, (uint64_t)src_id, 0, (int)lnum-1, hl_start, (int)lnum-1+end_off, hl_end, - decor, kExtmarkUndo); + decor, kExtmarkNoUndo); } } diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua index a9d4c72d31..daf20c006c 100644 --- a/test/functional/api/highlight_spec.lua +++ b/test/functional/api/highlight_spec.lua @@ -7,6 +7,7 @@ local meths = helpers.meths local funcs = helpers.funcs local pcall_err = helpers.pcall_err local ok = helpers.ok +local assert_alive = helpers.assert_alive describe('API: highlight',function() local expected_rgb = { @@ -145,4 +146,15 @@ describe('API: highlight',function() eq({foreground=tonumber("0x888888"), background=tonumber("0x888888")}, meths.get_hl_by_name("Shrubbery", true)) end) + + it("nvim_buf_add_highlight to other buffer doesn't crash if undo is disabled #12873", function() + command('vsplit file') + local err, _ = pcall(meths.buf_set_option, 1, 'undofile', false) + eq(true, err) + err, _ = pcall(meths.buf_set_option, 1, 'undolevels', -1) + eq(true, err) + err, _ = pcall(meths.buf_add_highlight, 1, -1, 'Question', 0, 0, -1) + eq(true, err) + assert_alive() + end) end) diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 74e85212c8..16c5477ee4 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -2750,6 +2750,26 @@ it(':substitute with inccommand, timer-induced :redraw #9777', function() ]]) end) +it(":substitute doesn't crash with inccommand, if undo is empty #12932", function() + local screen = Screen.new(10,5) + clear() + command('set undolevels=-1') + common_setup(screen, 'split', 'test') + feed(':%s/test') + sleep(100) + feed('/') + sleep(100) + feed('f') + screen:expect([[ + {12:f} | + {15:~ }| + {15:~ }| + {15:~ }| + :%s/test/f^ | + ]]) + assert_alive() +end) + it('long :%s/ with inccommand does not collapse cmdline', function() local screen = Screen.new(10,5) clear() From b2f9c2b6c19ce9b66bf278b487d3fe59bf26304f Mon Sep 17 00:00:00 2001 From: erw7 Date: Wed, 23 Sep 2020 10:55:13 +0900 Subject: [PATCH 04/10] undo: fix possibility of aborting --- src/nvim/undo.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 97018f6c02..903e57732f 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -3029,8 +3029,6 @@ u_header_T *u_force_get_undo_header(buf_T *buf) curbuf = buf; // Args are tricky: this means replace empty range by empty range.. u_savecommon(0, 1, 1, true); - curbuf = save_curbuf; - uhp = buf->b_u_curhead; if (!uhp) { uhp = buf->b_u_newhead; @@ -3038,6 +3036,7 @@ u_header_T *u_force_get_undo_header(buf_T *buf) abort(); } } + curbuf = save_curbuf; } return uhp; } From f1b39f91a5be7f3bf61b0e0d129dce49d51ff360 Mon Sep 17 00:00:00 2001 From: erw7 Date: Fri, 25 Sep 2020 09:26:44 +0900 Subject: [PATCH 05/10] extmark: Change nvim_buf_set_extmark to not create undo data --- src/nvim/api/buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 2eeaeae522..174f6e94a9 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -1420,7 +1420,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, } id = extmark_set(buf, (uint64_t)ns_id, id, - (int)line, (colnr_T)col, line2, col2, decor, kExtmarkUndo); + (int)line, (colnr_T)col, line2, col2, decor, kExtmarkNoUndo); return (Integer)id; From 72914cd7f21570a725fdace9c9fe2b171ec4c107 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 1 Oct 2020 21:46:16 -0400 Subject: [PATCH 06/10] vim-patch:8.2.1779: some debian changelog files are not recognized Problem: Some debian changelog files are not recognized. Solution: Add */debian/changelog. (Jason Franklin) https://github.com/vim/vim/commit/0022675aa362da0969666e48ced252b57ca1f79e --- runtime/filetype.vim | 2 +- src/nvim/testdir/test_filetype.vim | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/filetype.vim b/runtime/filetype.vim index c464e8cebd..7accc22b3d 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -313,7 +313,7 @@ au BufNewFile,BufRead *.css setf css au BufNewFile,BufRead *.con setf cterm " Changelog -au BufNewFile,BufRead changelog.Debian,changelog.dch,NEWS.Debian,NEWS.dch +au BufNewFile,BufRead changelog.Debian,changelog.dch,NEWS.Debian,NEWS.dch,*/debian/changelog \ setf debchangelog au BufNewFile,BufRead [cC]hange[lL]og diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index 9f8939f2f6..c7ca682c8c 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -128,6 +128,7 @@ let s:filename_checks = { \ 'dart': ['file.dart', 'file.drt'], \ 'datascript': ['file.ds'], \ 'dcd': ['file.dcd'], + \ 'debchangelog': ['changelog.Debian', 'changelog.dch', 'NEWS.Debian', 'NEWS.dch', '/debian/changelog'], \ 'debcontrol': ['/debian/control'], \ 'debsources': ['/etc/apt/sources.list', '/etc/apt/sources.list.d/file.list'], \ 'def': ['file.def'], From 25513049b3c3f9276dfa560ef0920f3ed6cc5f2f Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 1 Oct 2020 21:47:35 -0400 Subject: [PATCH 07/10] vim-patch:8.2.1780: statusline not updated when splitting windows Problem: Statusline not updated when splitting windows. Solution: Call status_redraw_all(). (Jason Franklin, closes vim/vim#5496) https://github.com/vim/vim/commit/668008be66326ed9e5b1122abede34ed3d2de2d8 --- src/nvim/testdir/test_statusline.vim | 19 +++++++++++++++++++ src/nvim/window.c | 8 +++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/nvim/testdir/test_statusline.vim b/src/nvim/testdir/test_statusline.vim index 8c81ec3431..7efd181d04 100644 --- a/src/nvim/testdir/test_statusline.vim +++ b/src/nvim/testdir/test_statusline.vim @@ -412,3 +412,22 @@ func Test_statusline_removed_group() call StopVimInTerminal(buf) call delete('XTest_statusline') endfunc + +func Test_statusline_after_split_vsplit() + only + + " Make the status line of each window show the window number. + set ls=2 stl=%{winnr()} + + split | redraw + vsplit | redraw + + " The status line of the third window should read '3' here. + call assert_equal('3', nr2char(screenchar(&lines - 1, 1))) + + only + set ls& stl& +endfunc + + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/window.c b/src/nvim/window.c index 6608deb231..e53570edd8 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1490,13 +1490,11 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir) if (flags & (WSP_TOP | WSP_BOT)) (void)win_comp_pos(); - /* - * Both windows need redrawing - */ + // Both windows need redrawing. Update all status lines, in case they + // show something related to the window count or position. redraw_win_later(wp, NOT_VALID); - wp->w_redr_status = TRUE; redraw_win_later(oldwin, NOT_VALID); - oldwin->w_redr_status = TRUE; + status_redraw_all(); if (need_status) { msg_row = Rows - 1; From 2000e1621d5e529d660dc0a7534f0884b6179c8b Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 2 Oct 2020 22:46:54 -0400 Subject: [PATCH 08/10] vim-patch:8.2.1787: crash with 'incsearch' and very long line Problem: Crash with 'incsearch' and very long line. Solution: Check whether regprog becomes NULL. (closes vim/vim#7063) https://github.com/vim/vim/commit/795aaa1e84d76a6fe066694de9876b8a21cbe40c N/A patches for version.c: vim-patch:8.2.1784: commits are not scanned for security problems Problem: commits are not scanned for security problems Solution: Enable Github code scanning. (Christian Brabandt, closes vim/vim#7057) https://github.com/vim/vim/commit/fa79be6b10e1d34fd697a56e85f6c0ce101f3d62 --- src/nvim/search.c | 27 ++++++++++++++++++++++----- src/nvim/testdir/test_search.vim | 15 +++++++++++++++ 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/nvim/search.c b/src/nvim/search.c index b053459c7f..ea2107c5c7 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -651,6 +651,10 @@ int searchit( colnr_T col = at_first_line && (options & SEARCH_COL) ? pos->col : 0; nmatched = vim_regexec_multi(®match, win, buf, lnum, col, tm, timed_out); + // vim_regexec_multi() may clear "regprog" + if (regmatch.regprog == NULL) { + break; + } // Abort searching on an error (e.g., out of stack). if (called_emsg || (timed_out != NULL && *timed_out)) { break; @@ -722,6 +726,10 @@ int searchit( match_ok = false; break; } + // vim_regexec_multi() may clear "regprog" + if (regmatch.regprog == NULL) { + break; + } matchpos = regmatch.startpos[0]; endpos = regmatch.endpos[0]; submatch = first_submatch(®match); @@ -811,10 +819,13 @@ int searchit( } break; } - - /* Need to get the line pointer again, a - * multi-line search may have made it invalid. */ - ptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE); + // vim_regexec_multi() may clear "regprog" + if (regmatch.regprog == NULL) { + break; + } + // Need to get the line pointer again, a + // multi-line search may have made it invalid. + ptr = ml_get_buf(buf, lnum + matchpos.lnum, false); } /* @@ -891,6 +902,11 @@ int searchit( } at_first_line = FALSE; + // vim_regexec_multi() may clear "regprog" + if (regmatch.regprog == NULL) { + break; + } + // Stop the search if wrapscan isn't set, "stop_lnum" is // specified, after an interrupt, after a match and after looping // twice. @@ -4243,7 +4259,8 @@ is_zero_width(char_u *pattern, int move, pos_T *cur, Direction direction) if (nmatched != 0) { break; } - } while (direction == FORWARD + } while (regmatch.regprog != NULL + && direction == FORWARD ? regmatch.startpos[0].col < pos.col : regmatch.startpos[0].col > pos.col); diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index 211fc73562..5db23c22a8 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -981,6 +981,21 @@ func Test_incsearch_substitute() call Incsearch_cleanup() endfunc +func Test_incsearch_substitute_long_line() + throw 'skipped: Nvim does not support test_override()' + new + call test_override("char_avail", 1) + set incsearch + + call repeat('x', 100000)->setline(1) + call feedkeys(':s/\%c', 'xt') + redraw + call feedkeys("\", 'xt') + + call Incsearch_cleanup() + bwipe! +endfunc + func Test_search_undefined_behaviour() if !has("terminal") return From 970d6ee0d1fafb92eeaa56a3d767e704c6ef42c2 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 2 Oct 2020 01:05:12 -0400 Subject: [PATCH 09/10] vim-patch:8.1.2143: cannot see each command even when 'verbose' is set Problem: Cannot see each command even when 'verbose' is set. Solution: List each command when 'verbose' is at least 16. https://github.com/vim/vim/commit/4facea310c2788c88f021b262658b847381a50a8 Cherry-pick Test_tselect() from patch 8.1.2141. It requires screendump so it won't run. I cannot port it to a lua screen test. --- src/nvim/ex_docmd.c | 36 ++++++++++++++++++++++--------- src/nvim/testdir/test_cmdline.vim | 23 ++++++++++++++++++++ src/nvim/testdir/test_tagjump.vim | 34 +++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 10 deletions(-) diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 7bb4bd32a3..a4ed86e4c0 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -258,6 +258,27 @@ void do_exmode(int improved) msg_scroll = save_msg_scroll; } +// Print the executed command for when 'verbose' is set. +// When "lnum" is 0 only print the command. +static void msg_verbose_cmd(linenr_T lnum, char_u *cmd) + FUNC_ATTR_NONNULL_ALL +{ + no_wait_return++; + verbose_enter_scroll(); + + if (lnum == 0) { + smsg(_("Executing: %s"), cmd); + } else { + smsg(_("line %" PRIdLINENR ": %s"), lnum, cmd); + } + if (msg_silent == 0) { + msg_puts("\n"); // don't overwrite this + } + + verbose_leave_scroll(); + no_wait_return--; +} + /* * Execute a simple command line. Used for translated commands like "*". */ @@ -568,16 +589,7 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, } if (p_verbose >= 15 && sourcing_name != NULL) { - ++no_wait_return; - verbose_enter_scroll(); - - smsg(_("line %" PRIdLINENR ": %s"), sourcing_lnum, cmdline_copy); - if (msg_silent == 0) { - msg_puts("\n"); // don't overwrite this either - } - - verbose_leave_scroll(); - --no_wait_return; + msg_verbose_cmd(sourcing_lnum, cmdline_copy); } /* @@ -1269,6 +1281,10 @@ static char_u * do_one_cmd(char_u **cmdlinep, goto doend; } + if (p_verbose >= 16) { + msg_verbose_cmd(0, *cmdlinep); + } + // 1. Skip comment lines and leading white space and colons. // 2. Handle command modifiers. diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index f8d84f1a49..27db957149 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -1,5 +1,8 @@ " Tests for editing the command line. +source check.vim +source screendump.vim + func Test_complete_tab() call writefile(['testfile'], 'Xtestfile') call feedkeys(":e Xtestf\t\r", "tx") @@ -718,6 +721,26 @@ func Test_verbosefile() call delete('Xlog') endfunc +func Test_verbose_option() + CheckScreendump + + let lines =<< trim [SCRIPT] + command DoSomething echo 'hello' |set ts=4 |let v = '123' |echo v + call feedkeys("\r", 't') " for the hit-enter prompt + set verbose=20 + [SCRIPT] + call writefile(lines, 'XTest_verbose') + + let buf = RunVimInTerminal('-S XTest_verbose', {'rows': 12}) + call term_wait(buf, 100) + call term_sendkeys(buf, ":DoSomething\") + call VerifyScreenDump(buf, 'Test_verbose_option_1', {}) + + " clean up + call StopVimInTerminal(buf) + call delete('XTest_verbose') +endfunc + func Test_setcmdpos() func InsertTextAtPos(text, pos) call assert_equal(0, setcmdpos(a:pos)) diff --git a/src/nvim/testdir/test_tagjump.vim b/src/nvim/testdir/test_tagjump.vim index 6abe5b7c89..7057cdefb2 100644 --- a/src/nvim/testdir/test_tagjump.vim +++ b/src/nvim/testdir/test_tagjump.vim @@ -1,5 +1,8 @@ " Tests for tagjump (tags and special searches) +source check.vim +source screendump.vim + " SEGV occurs in older versions. (At least 7.4.1748 or older) func Test_ptag_with_notagstack() set notagstack @@ -551,6 +554,37 @@ func Test_tag_line_toolong() let &verbose = old_vbs endfunc +" Check that using :tselect does not run into the hit-enter prompt. +" Requires a terminal to trigger that prompt. +func Test_tselect() + CheckScreendump + + call writefile([ + \ 'main Xtest.h /^void test();$/;" f', + \ 'main Xtest.c /^int main()$/;" f', + \ 'main Xtest.x /^void test()$/;" f', + \ ], 'Xtags') + cal writefile([ + \ 'int main()', + \ 'void test()', + \ ], 'Xtest.c') + + let lines =<< trim [SCRIPT] + set tags=Xtags + [SCRIPT] + call writefile(lines, 'XTest_tselect') + let buf = RunVimInTerminal('-S XTest_tselect', {'rows': 10, 'cols': 50}) + + call term_wait(buf, 100) + call term_sendkeys(buf, ":tselect main\2\") + call VerifyScreenDump(buf, 'Test_tselect_1', {}) + + call StopVimInTerminal(buf) + call delete('Xtags') + call delete('Xtest.c') + call delete('XTest_tselect') +endfunc + func Test_tagline() call writefile([ \ 'provision Xtest.py /^ def provision(self, **kwargs):$/;" m line:1 language:Python class:Foo', From 86ab4a1cb4cbf377d2ddf90f785d811a0be50cfc Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 2 Oct 2020 01:22:30 -0400 Subject: [PATCH 10/10] vim-patch:8.2.0841: 'verbose' value 16 causes duplicate output Problem: 'verbose' value 16 causes duplicate output. Solution: Combine levels 15 and 16 into one message. (Christian Brabandt, closes vim/vim#6153) https://github.com/vim/vim/commit/823654bc06c847af20967d41db32d592aba416cb --- runtime/doc/options.txt | 4 +++- src/nvim/ex_docmd.c | 6 +----- src/nvim/testdir/test_cmdline.vim | 1 + test/functional/ui/cmdline_spec.lua | 32 +++++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index bd61d113fb..beb5e9f4c2 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -6505,7 +6505,9 @@ A jump table for the options with a short description can be found at |Q_op|. >= 12 Every executed function. >= 13 When an exception is thrown, caught, finished, or discarded. >= 14 Anything pending in a ":finally" clause. - >= 15 Every executed Ex command (truncated at 200 characters). + >= 15 Every executed Ex command from a script (truncated at 200 + characters). + >= 16 Every executed Ex command This option can also be set with the "-V" argument. See |-V|. This option is also set by the |:verbose| command. diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index a4ed86e4c0..ccaa0b0e52 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -588,7 +588,7 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, } } - if (p_verbose >= 15 && sourcing_name != NULL) { + if ((p_verbose >= 15 && sourcing_name != NULL) || p_verbose >= 16) { msg_verbose_cmd(sourcing_lnum, cmdline_copy); } @@ -1281,10 +1281,6 @@ static char_u * do_one_cmd(char_u **cmdlinep, goto doend; } - if (p_verbose >= 16) { - msg_verbose_cmd(0, *cmdlinep); - } - // 1. Skip comment lines and leading white space and colons. // 2. Handle command modifiers. diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 27db957149..871143699a 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -722,6 +722,7 @@ func Test_verbosefile() endfunc func Test_verbose_option() + " See test/functional/ui/cmdline_spec.lua CheckScreendump let lines =<< trim [SCRIPT] diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 21c01b3458..01f0d8a4d7 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -3,6 +3,7 @@ local Screen = require('test.functional.ui.screen') local clear, feed = helpers.clear, helpers.feed local source = helpers.source local command = helpers.command +local feed_command = helpers.feed_command local function new_screen(opt) local screen = Screen.new(25, 5) @@ -842,3 +843,34 @@ describe('cmdline redraw', function() ]], unchanged=true} end) end) + +describe('cmdline', function() + before_each(function() + clear() + end) + + it('prints every executed Ex command if verbose >= 16', function() + local screen = Screen.new(50, 12) + screen:attach() + source([[ + command DoSomething echo 'hello' |set ts=4 |let v = '123' |echo v + call feedkeys("\r", 't') " for the hit-enter prompt + set verbose=20 + ]]) + feed_command('DoSomething') + screen:expect([[ + | + ~ | + | + Executing: DoSomething | + Executing: echo 'hello' |set ts=4 |let v = '123' || + echo v | + hello | + Executing: set ts=4 |let v = '123' |echo v | + Executing: let v = '123' |echo v | + Executing: echo v | + 123 | + Press ENTER or type command to continue^ | + ]]) + end) +end)