diff options
-rw-r--r-- | .github/workflows/ci.yml | 1 | ||||
-rw-r--r-- | .github/workflows/release.yml | 1 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/diagnostic.lua | 4 | ||||
-rw-r--r-- | src/nvim/api/vim.c | 1 | ||||
-rw-r--r-- | src/nvim/eval.c | 10 | ||||
-rw-r--r-- | src/nvim/eval/funcs.c | 2 | ||||
-rw-r--r-- | src/nvim/eval/userfunc.c | 4 | ||||
-rw-r--r-- | src/nvim/ex_cmds2.c | 2 | ||||
-rw-r--r-- | src/nvim/ex_session.c | 4 | ||||
-rw-r--r-- | src/nvim/indent_c.c | 2 | ||||
-rw-r--r-- | src/nvim/marktree.c | 2 | ||||
-rw-r--r-- | src/nvim/memline.c | 2 | ||||
-rw-r--r-- | src/nvim/normal.c | 4 | ||||
-rw-r--r-- | src/nvim/regexp.c | 2 | ||||
-rw-r--r-- | src/nvim/regexp_nfa.c | 8 | ||||
-rw-r--r-- | src/nvim/screen.c | 2 | ||||
-rw-r--r-- | src/nvim/sign.c | 6 | ||||
-rw-r--r-- | src/nvim/testdir/test_popup.vim | 101 | ||||
-rw-r--r-- | src/nvim/undo.c | 4 | ||||
-rw-r--r-- | src/nvim/version.c | 4 | ||||
-rw-r--r-- | src/nvim/window.c | 7 | ||||
-rw-r--r-- | test/functional/eval/null_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/fixtures/streams-test.c | 17 |
23 files changed, 141 insertions, 51 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86be9adabb..72a6be304c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,6 @@ jobs: run: | # Workaround brew issues rm -f /usr/local/bin/2to3 - brew unlink gcc@8 gcc@9 brew update >/dev/null brew upgrade brew install automake ccache perl cpanminus ninja diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a94b3d0a87..8c2333e68d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -76,7 +76,6 @@ jobs: - name: Install brew packages run: | rm -f /usr/local/bin/2to3 - brew unlink gcc@8 gcc@9 brew update >/dev/null brew upgrade brew install automake ninja diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua index 6a7dc1bbb0..ebd5773d6e 100644 --- a/runtime/lua/vim/lsp/diagnostic.lua +++ b/runtime/lua/vim/lsp/diagnostic.lua @@ -1217,13 +1217,11 @@ function M.set_loclist(opts) local row = pos.line local col = util.character_offset(bufnr, row, pos.character) - local line = (api.nvim_buf_get_lines(bufnr, row, row + 1, false) or {""})[1] - table.insert(items, { bufnr = bufnr, lnum = row + 1, col = col + 1, - text = line .. " | " .. diag.message, + text = diag.message, type = loclist_type_map[diag.severity or DiagnosticSeverity.Error] or 'E', }) end diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 99a41f4f6f..60535b13b3 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -2954,6 +2954,7 @@ void nvim_set_decoration_provider(Integer ns_id, DictionaryOf(LuaRef) opts, FUNC_API_SINCE(7) FUNC_API_LUA_ONLY { DecorProvider *p = get_decor_provider((NS)ns_id, true); + assert(p != NULL); decor_provider_clear(p); // regardless of what happens, it seems good idea to redraw diff --git a/src/nvim/eval.c b/src/nvim/eval.c index a75cc78b7e..a3fa9c986f 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -7200,9 +7200,13 @@ bool callback_from_typval(Callback *const callback, typval_T *const arg) r = FAIL; } else if (arg->v_type == VAR_FUNC || arg->v_type == VAR_STRING) { char_u *name = arg->vval.v_string; - func_ref(name); - callback->data.funcref = vim_strsave(name); - callback->type = kCallbackFuncref; + if (name != NULL) { + func_ref(name); + callback->data.funcref = vim_strsave(name); + callback->type = kCallbackFuncref; + } else { + r = FAIL; + } } else if (nlua_is_table_from_lua(arg)) { char_u *name = nlua_register_table_as_callable(arg); 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); } 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++; diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 0a2802397d..56a14887df 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2958,7 +2958,7 @@ int do_source(char_u *fname, int check_other, int is_vimrc) } if (l_do_profiling == PROF_YES) { - bool forceit; + bool forceit = false; // Check if we do profiling for this script. if (!si->sn_prof_on && has_profiling(true, si->sn_name, &forceit)) { diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index c1e52d6994..67b8e7e92f 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -725,7 +725,7 @@ static int makeopens(FILE *fd, char_u *dirnow) } } - if (tab_firstwin->w_next != NULL) { + if (tab_firstwin != NULL && tab_firstwin->w_next != NULL) { // Go to the first window. PUTLINE_FAIL("wincmd t"); @@ -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"); 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; diff --git a/src/nvim/marktree.c b/src/nvim/marktree.c index b3afdefac1..34acf64d83 100644 --- a/src/nvim/marktree.c +++ b/src/nvim/marktree.c @@ -849,7 +849,7 @@ bool marktree_splice(MarkTree *b, MarkTreeIter itr[1] = { 0 }; MarkTreeIter enditr[1] = { 0 }; - mtpos_t oldbase[MT_MAX_DEPTH]; + mtpos_t oldbase[MT_MAX_DEPTH] = { 0 }; marktree_itr_get_ext(b, start, itr, false, true, oldbase); if (!itr->node) { 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 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; } 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); 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 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; - } } } diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim index 9443958984..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\<CR>") + call term_sendkeys(buf, "/X\<CR>:popup PopUp\<CR>") + 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\<CR>") + call VerifyScreenDump(buf, 'Test_popup_command_03', {}) + + call term_sendkeys(buf, "\<Esc>") + call StopVimInTerminal(buf) + call delete('Xtest') +endfunc + func Test_popup_complete_backwards() new call setline(1, ['Post', 'Port', 'Po']) @@ -1077,4 +1105,77 @@ func Test_pum_getpos() unlet g:pum_pos endfunc +" Test for the popup menu with the 'rightleft' option set +func Test_pum_rightleft() + CheckFeature 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\<C-P>") + call term_wait(buf) + call VerifyScreenDump(buf, 'Test_pum_rightleft_01', {'rows': 8}) + call term_sendkeys(buf, "\<C-P>\<C-Y>") + 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, "\<Esc>:e! Xtest2\<CR>") + call term_wait(buf) + call term_sendkeys(buf, "Goone\<C-X>\<C-L>") + call term_wait(buf) + redraw! + call VerifyScreenDump(buf, 'Test_pum_rightleft_02', {'rows': 7}) + call term_sendkeys(buf, "\<C-Y>") + 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\<C-P>\<C-P>\<C-P>") + call term_wait(buf) + call VerifyScreenDump(buf, 'Test_pum_scrollbar_01', {'rows': 7}) + call term_sendkeys(buf, "\<C-E>\<Esc>dd") + call term_wait(buf) + + if has('rightleft') + call term_sendkeys(buf, ":set rightleft\<CR>") + call term_wait(buf) + call term_sendkeys(buf, "Go\<C-P>\<C-P>\<C-P>") + call term_wait(buf) + call VerifyScreenDump(buf, 'Test_pum_scrollbar_02', {'rows': 7}) + endif + + call StopVimInTerminal(buf) + call delete('Xtest1') +endfunc + " vim: shiftwidth=2 sts=2 expandtab 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; diff --git a/src/nvim/version.c b/src/nvim/version.c index deba3f6e49..f3a30630f8 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -406,13 +406,13 @@ static const int included_patches[] = { 1514, 1513, 1512, - // 1511, + 1511, 1510, 1509, 1508, 1507, 1506, - // 1505, + 1505, 1504, 1503, 1502, 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); diff --git a/test/functional/eval/null_spec.lua b/test/functional/eval/null_spec.lua index 8f0041ff27..b1ceff9115 100644 --- a/test/functional/eval/null_spec.lua +++ b/test/functional/eval/null_spec.lua @@ -150,6 +150,7 @@ describe('NULL', function() null_test('does not crash :execute', 'execute S', 0) null_expr_test('does not crash execute()', 'execute(S)', 0, '') null_expr_test('makes executable() error out', 'executable(S)', 'E928: String required', 0) + null_expr_test('makes timer_start() error out', 'timer_start(0, S)', 'E921: Invalid callback argument', -1) null_expr_test('does not crash filereadable()', 'filereadable(S)', 0, 0) null_expr_test('does not crash filewritable()', 'filewritable(S)', 0, 0) null_expr_test('does not crash fnamemodify()', 'fnamemodify(S, S)', 0, '') @@ -162,7 +163,6 @@ describe('NULL', function() null_expr_test('does not crash mkdir()', 'mkdir(S)', 0, 0) null_expr_test('does not crash sort()', 'sort(["b", S, "a"])', 0, {'', 'a', 'b'}) null_expr_test('does not crash split()', 'split(S)', 0, {}) - null_test('can be used to set an option', 'let &grepprg = S', 0) null_expr_test('is equal to non-existent variable', 'S == V', 0, 1) diff --git a/test/functional/fixtures/streams-test.c b/test/functional/fixtures/streams-test.c index eec447153c..be40edfe7e 100644 --- a/test/functional/fixtures/streams-test.c +++ b/test/functional/fixtures/streams-test.c @@ -6,23 +6,22 @@ #include <uv.h> -uv_loop_t *loop; -uv_process_t child_req; -uv_process_options_t options; - int main(int argc, char **argv) { - loop = uv_default_loop(); + uv_loop_t *loop = uv_default_loop(); + uv_process_t child_req; char * args[3]; args[0] = "sleep"; args[1] = "10"; args[2] = NULL; - options.exit_cb = NULL; - options.file = "sleep"; - options.args = args; - options.flags = UV_PROCESS_DETACHED; + uv_process_options_t options = { + .exit_cb = NULL, + .file = "sleep", + .args = args, + .flags = UV_PROCESS_DETACHED, + }; int r; if ((r = uv_spawn(loop, &child_req, &options))) { |