From 1b13c744eabaa08a4be0d114c35415c87c4e41cc Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 4 Jun 2021 21:50:32 -0400 Subject: vim-patch:8.2.2877: insufficient tests for popup menu rightleft Problem: Insufficient tests for popup menu rightleft. Solution: Add tests. (Yegappan Lakshmanan, closes vim/vim#8235) https://github.com/vim/vim/commit/1e615669c0f1f4125001b2c01c30b00d8c68035e --- src/nvim/testdir/test_popup.vim | 69 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'src') diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim index 9443958984..e28edeff27 100644 --- a/src/nvim/testdir/test_popup.vim +++ b/src/nvim/testdir/test_popup.vim @@ -1077,4 +1077,73 @@ func Test_pum_getpos() unlet g:pum_pos endfunc +" Test for the popup menu with the 'rightleft' option set +func Test_pum_rightleft() + CheckScreendump + let lines =<< trim END + abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz + vim + victory + END + call writefile(lines, 'Xtest1') + let buf = RunVimInTerminal('--cmd "set rightleft" Xtest1', {}) + call term_wait(buf) + call term_sendkeys(buf, "Go\") + call term_wait(buf) + call VerifyScreenDump(buf, 'Test_pum_rightleft_01', {'rows': 8}) + call term_sendkeys(buf, "\\") + call term_wait(buf) + redraw! + call assert_match('\s*miv', Screenline(5)) + + " Test for expanding tabs to spaces in the popup menu + let lines =<< trim END + one two + one three + four + END + call writefile(lines, 'Xtest2') + call term_sendkeys(buf, "\:e! Xtest2\") + call term_wait(buf) + call term_sendkeys(buf, "Goone\\") + call term_wait(buf) + redraw! + call VerifyScreenDump(buf, 'Test_pum_rightleft_02', {'rows': 7}) + call term_sendkeys(buf, "\") + call term_wait(buf) + redraw! + call assert_match('\s*eerht eno', Screenline(4)) + + call StopVimInTerminal(buf) + call delete('Xtest1') + call delete('Xtest2') +endfunc + +" Test for a popup menu with a scrollbar +func Test_pum_scrollbar() + CheckScreendump + let lines =<< trim END + one + two + three + END + call writefile(lines, 'Xtest1') + let buf = RunVimInTerminal('--cmd "set pumheight=2" Xtest1', {}) + call term_wait(buf) + call term_sendkeys(buf, "Go\\\") + call term_wait(buf) + call VerifyScreenDump(buf, 'Test_pum_scrollbar_01', {'rows': 7}) + call term_sendkeys(buf, "\\dd") + call term_wait(buf) + + call term_sendkeys(buf, ":set rightleft\") + call term_wait(buf) + call term_sendkeys(buf, "Go\\\") + call term_wait(buf) + call VerifyScreenDump(buf, 'Test_pum_scrollbar_02', {'rows': 7}) + + call StopVimInTerminal(buf) + call delete('Xtest1') +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From 60bf49ab1c80f23c533eb961457524b973e395ff Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 4 Jun 2021 21:51:13 -0400 Subject: vim-patch:8.2.2937: popup test fails if rightleft feature not enabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Popup test fails if rightleft feature not enabled. Solution: Check that the rightleft feature is available. (Dominique Pellé, closes vim/vim#8321) https://github.com/vim/vim/commit/56cddb38790ba535919524d9d2f32dbec9f3f07a --- src/nvim/testdir/test_popup.vim | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim index e28edeff27..027533e1ad 100644 --- a/src/nvim/testdir/test_popup.vim +++ b/src/nvim/testdir/test_popup.vim @@ -1079,7 +1079,9 @@ endfunc " Test for the popup menu with the 'rightleft' option set func Test_pum_rightleft() + CheckFeature rightleft CheckScreendump + let lines =<< trim END abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz vim @@ -1136,11 +1138,13 @@ func Test_pum_scrollbar() call term_sendkeys(buf, "\\dd") call term_wait(buf) - call term_sendkeys(buf, ":set rightleft\") - call term_wait(buf) - call term_sendkeys(buf, "Go\\\") - call term_wait(buf) - call VerifyScreenDump(buf, 'Test_pum_scrollbar_02', {'rows': 7}) + if has('rightleft') + call term_sendkeys(buf, ":set rightleft\") + call term_wait(buf) + call term_sendkeys(buf, "Go\\\") + call term_wait(buf) + call VerifyScreenDump(buf, 'Test_pum_scrollbar_02', {'rows': 7}) + endif call StopVimInTerminal(buf) call delete('Xtest1') -- cgit From b959de3a5fca16b9bbd49e30da5dfcbd62bd9970 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 4 Jun 2021 22:18:24 -0400 Subject: vim-patch:8.0.1578: no test for :popup in terminal Problem: No test for :popup in terminal. Solution: Add a screen dump test. https://github.com/vim/vim/commit/69f5a3011d5a93e0d54837e97d625bd6c253d897 --- src/nvim/testdir/test_popup.vim | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src') diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim index 027533e1ad..06bdb1236a 100644 --- a/src/nvim/testdir/test_popup.vim +++ b/src/nvim/testdir/test_popup.vim @@ -850,6 +850,34 @@ func Test_popup_position() call delete('Xtest') endfunc +func Test_popup_command() + if !CanRunVimInTerminal() || !has('menu') + return + endif + + call writefile([ + \ 'one two three four five', + \ 'and one two Xthree four five', + \ 'one more two three four five', + \ ], 'Xtest') + let buf = RunVimInTerminal('Xtest', {}) + call term_sendkeys(buf, ":source $VIMRUNTIME/menu.vim\") + call term_sendkeys(buf, "/X\:popup PopUp\") + call VerifyScreenDump(buf, 'Test_popup_command_01', {}) + + " Select a word + call term_sendkeys(buf, "jj") + call VerifyScreenDump(buf, 'Test_popup_command_02', {}) + + " Select a word + call term_sendkeys(buf, "j\") + call VerifyScreenDump(buf, 'Test_popup_command_03', {}) + + call term_sendkeys(buf, "\") + call StopVimInTerminal(buf) + call delete('Xtest') +endfunc + func Test_popup_complete_backwards() new call setline(1, ['Post', 'Port', 'Po']) -- cgit From 304c6ce93478d314461eae43dc6c673a2a4f74a0 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 4 Jun 2021 22:39:33 -0400 Subject: fixup! fixup! vim-patch:8.2.2776: :mksession uses current value of 'splitbelow' and 'splitright' (#14398) --- src/nvim/ex_session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 481febd16b..67b8e7e92f 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -835,7 +835,7 @@ static int makeopens(FILE *fd, char_u *dirnow) p_shm) < 0) { return FAIL; } - if (tab_firstwin->w_next != NULL) { + if (tab_firstwin != NULL && tab_firstwin->w_next != NULL) { // Restore 'winminheight' and 'winminwidth'. PUTLINE_FAIL("let &winminheight = s:save_winminheight"); PUTLINE_FAIL("let &winminwidth = s:save_winminwidth"); -- cgit From 729f270266dac57a9b214dc69a9a2249fe1a1ce6 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 5 Jun 2021 10:18:15 -0400 Subject: userfunc: pvs/v547 vim_strsave() returns nonnull. --- src/nvim/eval/userfunc.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src') diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index dc7027980e..f5d1b1e870 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -144,10 +144,6 @@ static int get_function_args(char_u **argp, char_u endchar, garray_T *newargs, c = *p; *p = NUL; expr = vim_strsave(expr); - if (expr == NULL) { - *p = c; - goto err_ret; - } ((char_u **)(default_args->ga_data)) [default_args->ga_len] = expr; default_args->ga_len++; -- cgit From 5115bc3f4f648b92f4c1eb47cd37aa8b682343a2 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 5 Jun 2021 11:40:07 -0400 Subject: sign: pvs/v547 vim_strsave() returns nonnull. --- src/nvim/sign.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src') diff --git a/src/nvim/sign.c b/src/nvim/sign.c index 97e64c6c4c..15fd25e096 100644 --- a/src/nvim/sign.c +++ b/src/nvim/sign.c @@ -2012,9 +2012,6 @@ int sign_place_from_dict( group = NULL; } else { group = vim_strsave(group); - if (group == NULL) { - return -1; - } } } @@ -2114,9 +2111,6 @@ int sign_unplace_from_dict(typval_T *group_tv, dict_T *dict) group = NULL; } else { group = vim_strsave(group); - if (group == NULL) { - return -1; - } } } -- cgit From 44b6a7b5bf55d441aa15f647dac133d159d5dbb4 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 5 Jun 2021 11:42:11 -0400 Subject: undo: pvs/v547 buf is nonnull when xfree(buf) is executed. free(NULL) is safe (for target compilers) so xfree(NULL) is also safe. --- src/nvim/undo.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/undo.c b/src/nvim/undo.c index f52850f6f3..ffd613cec2 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -1018,9 +1018,7 @@ static ExtmarkUndoObject *unserialize_extmark(bufinfo_T *bi, bool *error, goto error; } - if (buf) { - xfree(buf); - } + xfree(buf); return extup; -- cgit From 607d1cc80dc8c559684822ba2d35bb71f634aafa Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 5 Jun 2021 12:03:40 -0400 Subject: fixup! vim-patch:8.2.2136: Vim9: Using uninitialized variable Resolve pvs/v560 error. mods is nonnull in the modified inner if-condition. because it is checked for NULL in the outer if-condition. --- src/nvim/eval/funcs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index caaf675db2..ce09d268ea 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -2547,7 +2547,7 @@ static void f_fnamemodify(typval_T *argvars, typval_T *rettv, FunPtr fptr) } else { len = strlen(fname); size_t usedlen = 0; - if (mods != NULL && *mods != NUL) { + if (*mods != NUL) { (void)modify_fname((char_u *)mods, false, &usedlen, (char_u **)&fname, &fbuf, &len); } -- cgit From 3d120b1c181a7cc2d3b7ba9ce01651942104a02c Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 5 Jun 2021 12:18:18 -0400 Subject: screen: pvs/v614 win_col_offset must be 0 to be no-opt when passed to col_off param of draw_virt_text(). --- src/nvim/screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 90ac4ac7aa..844104e7d0 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -2101,7 +2101,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool search_attr_from_match = false; // if search_attr is from :match bool has_decor = false; // this buffer has decoration bool do_virttext = false; // draw virtual text for this line - int win_col_offset; // offsett for window columns + int win_col_offset = 0; // offset for window columns char_u buf_fold[FOLD_TEXT_LEN + 1]; // Hold value returned by get_foldtext -- cgit From ac64055826039623452a81c1d94166f1788992d0 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 5 Jun 2021 12:25:30 -0400 Subject: indent_c: pvs/v1071 "void" cast unused return value of find_last_paren(). --- src/nvim/indent_c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index 771bf923b2..25c27743f3 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -3552,7 +3552,7 @@ term_again: * Position the cursor over the rightmost paren, so that * matching it will take us back to the start of the line. */ - find_last_paren(l, '(', ')'); + (void)find_last_paren(l, '(', ')'); if ((trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) curwin->w_cursor = *trypos; -- cgit From c6b8598616a060628862ae908fd531d518c534ad Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 5 Jun 2021 12:27:28 -0400 Subject: memline: pvs/v1071 "void" cast unused return value of ml_find_line(). --- src/nvim/memline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 34d8eb0ffe..e42b138253 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -2238,7 +2238,7 @@ static int ml_append_int( */ lineadd = buf->b_ml.ml_locked_lineadd; buf->b_ml.ml_locked_lineadd = 0; - ml_find_line(buf, (linenr_T)0, ML_FLUSH); /* flush data block */ + (void)ml_find_line(buf, (linenr_T)0, ML_FLUSH); // flush data block /* * update pointer blocks for the new data block -- cgit From 61e07d98ddb9a3f141fc7534b0598b5677c3d004 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 5 Jun 2021 12:29:43 -0400 Subject: fold: pvs/v1071 "void" cast unused return value of hasFolding(). --- src/nvim/normal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 173d8d46d1..69afe1644e 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -5120,8 +5120,8 @@ static void nv_scroll(cmdarg_T *cap) /* Count a fold for one screen line. */ lnum = curwin->w_topline; while (n-- > 0 && lnum < curwin->w_botline - 1) { - hasFolding(lnum, NULL, &lnum); - ++lnum; + (void)hasFolding(lnum, NULL, &lnum); + lnum++; } n = lnum - curwin->w_topline; } -- cgit From 0aa16dbd180e920ed0de7bde383e01219746ba14 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 5 Jun 2021 12:46:43 -0400 Subject: regexp: pvs/v1071 "void" cast unused return values of getchr(), peekchr(). --- src/nvim/regexp.c | 2 +- src/nvim/regexp_nfa.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 6b84bb3207..c2ef217638 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -2912,7 +2912,7 @@ static int peekchr(void) at_start = false; // be able to say "/\*ptr" regparse++; after_slash++; - peekchr(); + (void)peekchr(); regparse--; after_slash--; curchr = toggle_Magic(curchr); diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 5047e0db03..35c3285cda 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -1461,10 +1461,10 @@ static int nfa_regatom(void) if (nfa_regatom() == FAIL) return FAIL; } - getchr(); /* get the ] */ - if (n == 0) - EMSG2_RET_FAIL(_(e_empty_sb), - reg_magic == MAGIC_ALL); + (void)getchr(); // get the ] + if (n == 0) { + EMSG2_RET_FAIL(_(e_empty_sb), reg_magic == MAGIC_ALL); + } EMIT(NFA_OPT_CHARS); EMIT(n); -- cgit From 77b24c867bf55c84bf7c7b13c33bd7ee33880ac8 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 5 Jun 2021 12:48:26 -0400 Subject: window: pvs/v1071 "void" cast unused return value of win_comp_pos(). --- src/nvim/window.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/window.c b/src/nvim/window.c index cdeae2e294..aea60fe24c 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -2528,7 +2528,7 @@ int win_close(win_T *win, bool free_buf) // only resize that frame. Otherwise resize all windows. win_equal(curwin, curwin->w_frame->fr_parent == win_frame, dir); } else { - win_comp_pos(); + (void)win_comp_pos(); } } @@ -6296,9 +6296,10 @@ restore_snapshot ( && curtab->tp_snapshot[idx]->fr_height == topframe->fr_height && check_snapshot_rec(curtab->tp_snapshot[idx], topframe) == OK) { wp = restore_snapshot_rec(curtab->tp_snapshot[idx], topframe); - win_comp_pos(); - if (wp != NULL && close_curwin) + (void)win_comp_pos(); + if (wp != NULL && close_curwin) { win_goto(wp); + } redraw_all_later(NOT_VALID); } clear_snapshot(curtab, idx); -- cgit