aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-06-05 13:18:05 -0400
committerGitHub <noreply@github.com>2021-06-05 13:18:05 -0400
commitbecbb7436f7f027f0ff1fcf440334c0b3a9a8e1a (patch)
tree3bfbda933913e5a4636241439d4f350956126431 /src
parentbfcec8d2f03cb4eb7dc905e97b1f1c13c2ec2241 (diff)
parent77b24c867bf55c84bf7c7b13c33bd7ee33880ac8 (diff)
downloadrneovim-becbb7436f7f027f0ff1fcf440334c0b3a9a8e1a.tar.gz
rneovim-becbb7436f7f027f0ff1fcf440334c0b3a9a8e1a.tar.bz2
rneovim-becbb7436f7f027f0ff1fcf440334c0b3a9a8e1a.zip
Merge pull request #14724 from janlazo/vim-8.2.2877
vim-patch:8.0.1578,8.2.{2877,2937}
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval/funcs.c2
-rw-r--r--src/nvim/eval/userfunc.c4
-rw-r--r--src/nvim/ex_session.c2
-rw-r--r--src/nvim/indent_c.c2
-rw-r--r--src/nvim/memline.c2
-rw-r--r--src/nvim/normal.c4
-rw-r--r--src/nvim/regexp.c2
-rw-r--r--src/nvim/regexp_nfa.c8
-rw-r--r--src/nvim/screen.c2
-rw-r--r--src/nvim/sign.c6
-rw-r--r--src/nvim/testdir/test_popup.vim101
-rw-r--r--src/nvim/undo.c4
-rw-r--r--src/nvim/window.c7
13 files changed, 118 insertions, 28 deletions
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_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");
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/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/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);