From b8a56e0986c92f09b5a98003065630fd4c1bb48d Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 6 Nov 2019 00:21:26 -0500 Subject: vim-patch:8.1.2244: 'wrapscan' is not used for "gn" Problem: 'wrapscan' is not used for "gn". Solution: Only reset 'wrapscan' for the first search round. (closes vim/vim#5164) https://github.com/vim/vim/commit/82cf7f6df751505da285815a791463a049587849 --- src/nvim/search.c | 16 ++++++++-------- src/nvim/testdir/test_gn.vim | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/nvim/search.c b/src/nvim/search.c index c4c8633ed9..d396e7551b 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -4037,9 +4037,6 @@ current_search( bool old_p_ws = p_ws; pos_T save_VIsual = VIsual; - /* wrapping should not occur */ - p_ws = false; - /* Correct cursor when 'selection' is exclusive */ if (VIsual_active && *p_sel == 'e' && lt(VIsual, curwin->w_cursor)) dec_cursor(); @@ -4063,8 +4060,7 @@ current_search( int zero_width = is_zero_width(spats[last_idx].pat, true, &curwin->w_cursor, FORWARD); if (zero_width == -1) { - p_ws = old_p_ws; - return FAIL; /* pattern not found */ + return FAIL; // pattern not found } /* @@ -4081,11 +4077,18 @@ current_search( } end_pos = pos; + // wrapping should not occur in the first round + if (i == 0) { + p_ws = false; + } + result = searchit(curwin, curbuf, &pos, &end_pos, (dir ? FORWARD : BACKWARD), spats[last_idx].pat, i ? count : 1, SEARCH_KEEP | flags, RE_SEARCH, NULL); + p_ws = old_p_ws; + // First search may fail, but then start searching from the // beginning of the file (cursor might be on the search match) // except when Visual mode is active, so that extending the visual @@ -4094,7 +4097,6 @@ current_search( curwin->w_cursor = orig_pos; if (VIsual_active) VIsual = save_VIsual; - p_ws = old_p_ws; return FAIL; } else if (i == 0 && !result) { if (forward) { // try again from start of buffer @@ -4110,8 +4112,6 @@ current_search( pos_T start_pos = pos; - p_ws = old_p_ws; - if (!VIsual_active) { VIsual = start_pos; } diff --git a/src/nvim/testdir/test_gn.vim b/src/nvim/testdir/test_gn.vim index 834397126f..d41675be0c 100644 --- a/src/nvim/testdir/test_gn.vim +++ b/src/nvim/testdir/test_gn.vim @@ -136,8 +136,9 @@ func Test_gn_command() call assert_equal(['ABCDEFGHi'], getline(1,'$')) call setline('.', ['abcdefghi']) let @/ = 'b' + " this gn wraps around the end of the file exe "norm! 0fhvhhgngU" - call assert_equal(['abcdefghi'], getline(1,'$')) + call assert_equal(['aBCDEFGHi'], getline(1,'$')) sil! %d _ call setline('.', ['abcdefghi']) let @/ = 'f' -- cgit From 697b0d73a768da578b53d890300091fabceeeee0 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 6 Nov 2019 00:41:49 -0500 Subject: vim-patch:8.1.2258: may get hit-enter prompt after entering a number Problem: May get hit-enter prompt after entering a number. (Malcolm Rowe) Solution: Put back accidentally deleted lines. (closes vim/vim#5176) https://github.com/vim/vim/commit/dc968e7a45c672a81148628b755c2a440a228ad7 --- src/nvim/misc1.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index 1db8a1fa11..c1de7ab9a4 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -792,6 +792,8 @@ int prompt_for_number(int *mouse_used) cmdline_row = msg_row - 1; } need_wait_return = false; + msg_didany = false; + msg_didout = false; } else { cmdline_row = save_cmdline_row; } -- cgit From c3cb54b5ff20c1a126cbbe9b964ceebff0c60ded Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 6 Nov 2019 22:01:58 -0500 Subject: vim-patch:8.1.1091: MS-Windows: cannot use multi-byte chars in environment var Problem: MS-Windows: cannot use multi-byte chars in environment var. Solution: Use the wide API. (Ken Takata, closes vim/vim#4008) https://github.com/vim/vim/commit/f0908e6fe18943ad4453d7d6772fa43049aff4bc --- src/nvim/testdir/test_let.vim | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/nvim/testdir/test_let.vim b/src/nvim/testdir/test_let.vim index 1fce3d6937..988d248544 100644 --- a/src/nvim/testdir/test_let.vim +++ b/src/nvim/testdir/test_let.vim @@ -141,6 +141,11 @@ func Test_let_varg_fail() call s:set_varg8([0]) endfunction +func Test_let_utf8_environment() + let $a = 'ĀĒĪŌŪあいうえお' + call assert_equal('ĀĒĪŌŪあいうえお', $a) +endfunc + func Test_let_heredoc_fails() call assert_fails('let v =<< marker', 'E991:') -- cgit From 3e2f7baf2138c204a9d94e2dc2cae7900b0b6122 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 6 Nov 2019 22:32:54 -0500 Subject: vim-patch:8.1.2262: unpack assignment in function not recognized Problem: Unpack assignment in function not recognized. Solution: Skip over "[a, b]". (closes vim/vim#5051) https://github.com/vim/vim/commit/1e673b9eb686459bd0e7fc3f2199dd077546a18e --- src/nvim/eval.c | 37 +++++++++++++++++++++++-------------- src/nvim/testdir/test_let.vim | 8 ++++++++ 2 files changed, 31 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index fd83bc846b..e08e129656 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -21742,22 +21742,31 @@ void ex_function(exarg_T *eap) } // Check for ":let v =<< [trim] EOF" + // and ":let [a, b] =<< [trim] EOF" arg = skipwhite(skiptowhite(p)); - arg = skipwhite(skiptowhite(arg)); - if (arg[0] == '=' && arg[1] == '<' && arg[2] =='<' - && ((p[0] == 'l' && p[1] == 'e' - && (!ASCII_ISALNUM(p[2]) - || (p[2] == 't' && !ASCII_ISALNUM(p[3])))))) { - p = skipwhite(arg + 3); - if (STRNCMP(p, "trim", 4) == 0) { - // Ignore leading white space. - p = skipwhite(p + 4); - heredoc_trimmed = vim_strnsave(theline, - (int)(skipwhite(theline) - theline)); + if (*arg == '[') { + arg = vim_strchr(arg, ']'); + } + if (arg != NULL) { + arg = skipwhite(skiptowhite(arg)); + if (arg[0] == '=' + && arg[1] == '<' + && arg[2] =='<' + && (p[0] == 'l' + && p[1] == 'e' + && (!ASCII_ISALNUM(p[2]) + || (p[2] == 't' && !ASCII_ISALNUM(p[3]))))) { + p = skipwhite(arg + 3); + if (STRNCMP(p, "trim", 4) == 0) { + // Ignore leading white space. + p = skipwhite(p + 4); + heredoc_trimmed = + vim_strnsave(theline, (int)(skipwhite(theline) - theline)); + } + skip_until = vim_strnsave(p, (int)(skiptowhite(p) - p)); + do_concat = false; + is_heredoc = true; } - skip_until = vim_strnsave(p, (int)(skiptowhite(p) - p)); - do_concat = false; - is_heredoc = true; } } diff --git a/src/nvim/testdir/test_let.vim b/src/nvim/testdir/test_let.vim index 988d248544..3c0fefbd25 100644 --- a/src/nvim/testdir/test_let.vim +++ b/src/nvim/testdir/test_let.vim @@ -289,4 +289,12 @@ E END endif call assert_equal([], check) + + " unpack assignment + let [a, b, c] =<< END + x + \y + z +END + call assert_equal([' x', ' \y', ' z'], [a, b, c]) endfunc -- cgit From 805a577f71f385c783e5ae7604aac41f650c2de6 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 7 Nov 2019 23:00:27 -0500 Subject: vim-patch:8.1.2268: spell file flag zero is not recognized Problem: Spell file flag zero is not recognized. Solution: Use -1 as an error value, so that zero can be used as a valid flag number. https://github.com/vim/vim/commit/3d2a47c7823b934e1a85d773b68758c87c3ddc90 --- src/nvim/spellfile.c | 17 ++++++++++++++--- src/nvim/testdir/test_spell.vim | 9 ++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index eeec5be120..4fac001bc5 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -265,6 +265,8 @@ // follow; never used in prefix tree #define BY_SPECIAL BY_FLAGS2 // highest special byte value +#define ZERO_FLAG 65009 // used when flag is zero: "0" + // Flags used in .spl file for soundsalike flags. #define SAL_F0LLOWUP 1 #define SAL_COLLAPSE 2 @@ -2783,6 +2785,7 @@ static unsigned affitem2flag(int flagtype, char_u *item, char_u *fname, int lnum } // Get one affix name from "*pp" and advance the pointer. +// Returns ZERO_FLAG for "0". // Returns zero for an error, still advances the pointer then. static unsigned get_affitem(int flagtype, char_u **pp) { @@ -2794,6 +2797,9 @@ static unsigned get_affitem(int flagtype, char_u **pp) return 0; } res = getdigits_int(pp, true, 0); + if (res == 0) { + res = ZERO_FLAG; + } } else { res = mb_ptr2char_adv((const char_u **)pp); if (flagtype == AFT_LONG || (flagtype == AFT_CAPLONG @@ -2915,10 +2921,15 @@ static bool flag_in_afflist(int flagtype, char_u *afflist, unsigned flag) int digits = getdigits_int(&p, true, 0); assert(digits >= 0); n = (unsigned int)digits; - if (n == flag) + if (n == 0) { + n = ZERO_FLAG; + } + if (n == flag) { return true; - if (*p != NUL) // skip over comma - ++p; + } + if (*p != NUL) { // skip over comma + p++; + } } break; } diff --git a/src/nvim/testdir/test_spell.vim b/src/nvim/testdir/test_spell.vim index e49b5542fa..9dce87774b 100644 --- a/src/nvim/testdir/test_spell.vim +++ b/src/nvim/testdir/test_spell.vim @@ -283,9 +283,9 @@ func Test_zz_affix() \ ]) call LoadAffAndDic(g:test_data_aff7, g:test_data_dic7) - call RunGoodBad("meea1 meea\xE9 bar prebar barmeat prebarmeat leadprebar lead tail leadtail leadmiddletail", + call RunGoodBad("meea1 meezero meea\xE9 bar prebar barmeat prebarmeat leadprebar lead tail leadtail leadmiddletail", \ "bad: mee meea2 prabar probarmaat middle leadmiddle middletail taillead leadprobar", - \ ["bar", "barmeat", "lead", "meea1", "meea\xE9", "prebar", "prebarmeat", "tail"], + \ ["bar", "barmeat", "lead", "meea1", "meea\xE9", "meezero", "prebar", "prebarmeat", "tail"], \ [ \ ["bad", ["bar", "lead", "tail"]], \ ["mee", ["meea1", "meea\xE9", "bar"]], @@ -713,6 +713,9 @@ let g:test_data_aff7 = [ \"SFX 61003 Y 1", \"SFX 61003 0 meat .", \"", + \"SFX 0 Y 1", + \"SFX 0 0 zero .", + \"", \"SFX 391 Y 1", \"SFX 391 0 a1 .", \"", @@ -724,7 +727,7 @@ let g:test_data_aff7 = [ \ ] let g:test_data_dic7 = [ \"1234", - \"mee/391,111,9999", + \"mee/0,391,111,9999", \"bar/17,61003,123", \"lead/2", \"tail/123", -- cgit From 2a59ae0f1da613629c08ab16e062cb6fda6ee778 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 8 Nov 2019 21:59:31 -0500 Subject: vim-patch:8.1.2270: "gf" is not tested in Visual mode Problem: "gf" is not tested in Visual mode. Solution: Add Visual mode test and test errors. (Dominique Pelle, closes vim/vim#5197) https://github.com/vim/vim/commit/0208b6b771161d1a668b3568f71dc2bde3614933 --- src/nvim/testdir/test_gf.vim | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src') diff --git a/src/nvim/testdir/test_gf.vim b/src/nvim/testdir/test_gf.vim index accd21e9a3..d301874891 100644 --- a/src/nvim/testdir/test_gf.vim +++ b/src/nvim/testdir/test_gf.vim @@ -99,3 +99,28 @@ func Test_gf() call delete('Xtest1') call delete('Xtestgf') endfunc + +func Test_gf_visual() + call writefile([], "Xtest_gf_visual") + new + call setline(1, 'XXXtest_gf_visualXXX') + set hidden + + " Visually select Xtest_gf_visual and use gf to go to that file + norm! ttvtXgf + call assert_equal('Xtest_gf_visual', bufname('%')) + + bwipe! + call delete('Xtest_gf_visual') + set hidden& +endfunc + +func Test_gf_error() + new + call assert_fails('normal gf', 'E446:') + call assert_fails('normal gF', 'E446:') + call setline(1, '/doesnotexist') + call assert_fails('normal gf', 'E447:') + call assert_fails('normal gF', 'E447:') + bwipe! +endfunc -- cgit From 2ed23af9b2442ca61d2419d024b5e1a568398ef2 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 8 Nov 2019 22:02:08 -0500 Subject: vim-patch:8.1.2272: test may hang at more prompt Problem: Test may hang at more prompt. Solution: Reset 'more' after resetting 'compatible'. (Michael Soyka) https://github.com/vim/vim/commit/34059e7b67ae8a58dc2471b309afe05d9dde760f --- src/nvim/testdir/test_vimscript.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/testdir/test_vimscript.vim b/src/nvim/testdir/test_vimscript.vim index 3fcba4134e..d2f13ff072 100644 --- a/src/nvim/testdir/test_vimscript.vim +++ b/src/nvim/testdir/test_vimscript.vim @@ -1284,7 +1284,7 @@ func s:DoNothing() endfunc func Test_script_local_func() - set nocp viminfo+=nviminfo + set nocp nomore viminfo+=nviminfo new nnoremap _x :call DoNothing()call DoLast()delfunc DoNothingdelfunc DoLast -- cgit From 6e42eb4dc9d2c1f3b114651673e6f2699f2416a0 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 9 Nov 2019 09:56:36 -0500 Subject: vim-patch:8.1.0324: off-by-one error in cmdidx check Problem: Off-by-one error in cmdidx check. (Coverity) Solution: Use ">=" instead of ">". https://github.com/vim/vim/commit/74c8be2c6803eda3a57991b8867c5c65259b73d6 Fix pvs/v557. --- src/nvim/ex_docmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index d3e2120721..7d02623d67 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -10156,7 +10156,7 @@ static void ex_folddo(exarg_T *eap) bool is_loclist_cmd(int cmdidx) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { - if (cmdidx < 0 || cmdidx > CMD_SIZE) { + if (cmdidx < 0 || cmdidx >= CMD_SIZE) { return false; } return cmdnames[cmdidx].cmd_name[0] == 'l'; -- cgit From 099c38efed6cf5ca87dbff5c1d90a274991da4cf Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 9 Nov 2019 10:11:56 -0500 Subject: quickfix: fix pvs/v547 --- src/nvim/quickfix.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index cf5194d16f..da315252b5 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -1890,6 +1890,7 @@ static qf_info_T *qf_alloc_stack(qfltype_T qfltype) /// Return the location list stack for window 'wp'. /// If not present, allocate a location list stack static qf_info_T *ll_get_or_alloc_list(win_T *wp) + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET { if (IS_LL_WINDOW(wp)) /* For a location list window, use the referenced location list */ @@ -1931,17 +1932,14 @@ static qf_info_T * qf_cmd_get_stack(exarg_T *eap, int print_emsg) /// Get the quickfix/location list stack to use for the specified Ex command. /// For a location list command, returns the stack for the current window. /// If the location list is not present, then allocates a new one. -/// Returns NULL if the allocation fails. For a location list command, sets -/// 'pwinp' to curwin. -static qf_info_T * qf_cmd_get_or_alloc_stack(exarg_T *eap, win_T **pwinp) +/// For a location list command, sets 'pwinp' to curwin. +static qf_info_T *qf_cmd_get_or_alloc_stack(const exarg_T *eap, win_T **pwinp) + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET { qf_info_T *qi = &ql_info; if (is_loclist_cmd(eap->cmdidx)) { qi = ll_get_or_alloc_list(curwin); - if (qi == NULL) { - return NULL; - } *pwinp = curwin; } @@ -4968,7 +4966,6 @@ void ex_vimgrep(exarg_T *eap) char_u *s; char_u *p; int fi; - qf_info_T *qi; qf_list_T *qfl; win_T *wp = NULL; buf_T *buf; @@ -4994,10 +4991,7 @@ void ex_vimgrep(exarg_T *eap) } } - qi = qf_cmd_get_or_alloc_stack(eap, &wp); - if (qi == NULL) { - return; - } + qf_info_T *qi = qf_cmd_get_or_alloc_stack(eap, &wp); if (eap->addr_count > 0) tomatch = eap->line2; @@ -6304,7 +6298,6 @@ static int cbuffer_process_args(exarg_T *eap, void ex_cbuffer(exarg_T *eap) { buf_T *buf = NULL; - qf_info_T *qi; char_u *au_name = NULL; win_T *wp = NULL; char_u *qf_title; @@ -6320,10 +6313,7 @@ void ex_cbuffer(exarg_T *eap) } // Must come after autocommands. - qi = qf_cmd_get_or_alloc_stack(eap, &wp); - if (qi == NULL) { - return; - } + qf_info_T *qi = qf_cmd_get_or_alloc_stack(eap, &wp); if (cbuffer_process_args(eap, &buf, &line1, &line2) == FAIL) { return; @@ -6392,7 +6382,6 @@ static char_u * cexpr_get_auname(cmdidx_T cmdidx) /// ":lexpr {expr}", ":lgetexpr {expr}", ":laddexpr {expr}" command. void ex_cexpr(exarg_T *eap) { - qf_info_T *qi; char_u *au_name = NULL; win_T *wp = NULL; @@ -6404,10 +6393,7 @@ void ex_cexpr(exarg_T *eap) } } - qi = qf_cmd_get_or_alloc_stack(eap, &wp); - if (qi == NULL) { - return; - } + qf_info_T *qi = qf_cmd_get_or_alloc_stack(eap, &wp); /* Evaluate the expression. When the result is a string or a list we can * use it to fill the errorlist. */ -- cgit