diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-12-27 17:14:31 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-27 17:14:31 -0500 |
commit | a58c5509d94f01f4a4edd6b4784f8d00b70af5b3 (patch) | |
tree | b3cadc41e6fd4c747de5635dc0fb7556ec5e6e13 /src | |
parent | f2be59d8f80f2a1a68d5976b9cec3fa55da3700e (diff) | |
parent | cff4cad25a1236bd869843f9578b7f276518d9b8 (diff) | |
download | rneovim-a58c5509d94f01f4a4edd6b4784f8d00b70af5b3.tar.gz rneovim-a58c5509d94f01f4a4edd6b4784f8d00b70af5b3.tar.bz2 rneovim-a58c5509d94f01f4a4edd6b4784f8d00b70af5b3.zip |
Merge pull request #13607 from janlazo/vim-8.2.2221
vim-patch:8.1.2227,8.2.{315,928,1007,1052,1121,1580,2221,2229,2231,2232}
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/buffer.c | 2 | ||||
-rw-r--r-- | src/nvim/diff.c | 5 | ||||
-rw-r--r-- | src/nvim/edit.c | 2 | ||||
-rw-r--r-- | src/nvim/eval.c | 11 | ||||
-rw-r--r-- | src/nvim/eval/funcs.c | 4 | ||||
-rw-r--r-- | src/nvim/eval/userfunc.c | 4 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 9 | ||||
-rw-r--r-- | src/nvim/ex_cmds2.c | 10 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 19 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 8 | ||||
-rw-r--r-- | src/nvim/fileio.c | 11 | ||||
-rw-r--r-- | src/nvim/memline.c | 6 | ||||
-rw-r--r-- | src/nvim/regexp.c | 7 | ||||
-rw-r--r-- | src/nvim/regexp_nfa.c | 3 | ||||
-rw-r--r-- | src/nvim/syntax.c | 35 | ||||
-rw-r--r-- | src/nvim/testdir/test_clientserver.vim | 9 | ||||
-rw-r--r-- | src/nvim/testdir/test_cmdline.vim | 88 | ||||
-rw-r--r-- | src/nvim/window.c | 25 |
18 files changed, 185 insertions, 73 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index a8cb90ff0e..93a03986e5 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1587,7 +1587,7 @@ void enter_buffer(buf_T *buf) need_fileinfo = true; // display file info after redraw } // check if file changed - (void)buf_check_timestamp(curbuf, false); + (void)buf_check_timestamp(curbuf); curwin->w_topline = 1; curwin->w_topfill = 0; diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 1cdf84f9d0..93bc34fa4b 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -805,7 +805,7 @@ static void diff_try_update(diffio_T *dio, for (idx_new = idx_orig; idx_new < DB_COUNT; idx_new++) { buf = curtab->tp_diffbuf[idx_new]; if (buf_valid(buf)) { - buf_check_timestamp(buf, false); + buf_check_timestamp(buf); } } } @@ -1225,8 +1225,7 @@ void ex_diffpatch(exarg_T *eap) EMSG(_("E816: Cannot read patch output")); } else { if (curbuf->b_fname != NULL) { - newname = vim_strnsave(curbuf->b_fname, - (int)(STRLEN(curbuf->b_fname) + 4)); + newname = vim_strnsave(curbuf->b_fname, STRLEN(curbuf->b_fname) + 4); STRCAT(newname, ".new"); } diff --git a/src/nvim/edit.c b/src/nvim/edit.c index ebbb6e803a..36acc10f98 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -3423,7 +3423,7 @@ static void ins_compl_addleader(int c) xfree(compl_leader); compl_leader = vim_strnsave(get_cursor_line_ptr() + compl_col, - (int)(curwin->w_cursor.col - compl_col)); + curwin->w_cursor.col - compl_col); ins_compl_new_leader(); } diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 10a382ec4e..7916e3a66a 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -5422,7 +5422,7 @@ static int get_literal_key(char_u **arg, typval_T *tv) for (p = *arg; ASCII_ISALNUM(*p) || *p == '_' || *p == '-'; p++) { } tv->v_type = VAR_STRING; - tv->vval.v_string = vim_strnsave(*arg, (int)(p - *arg)); + tv->vval.v_string = vim_strnsave(*arg, p - *arg); *arg = skipwhite(p); return OK; @@ -10264,9 +10264,6 @@ repeat: if (src[*usedlen] == ':' && (src[*usedlen + 1] == 's' || (src[*usedlen + 1] == 'g' && src[*usedlen + 2] == 's'))) { - char_u *str; - char_u *pat; - char_u *sub; int sep; char_u *flags; int didit = FALSE; @@ -10283,13 +10280,13 @@ repeat: // find end of pattern p = vim_strchr(s, sep); if (p != NULL) { - pat = vim_strnsave(s, (int)(p - s)); + char_u *const pat = vim_strnsave(s, p - s); s = p + 1; // find end of substitution p = vim_strchr(s, sep); if (p != NULL) { - sub = vim_strnsave(s, (int)(p - s)); - str = vim_strnsave(*fnamep, *fnamelen); + char_u *const sub = vim_strnsave(s, p - s); + char_u *const str = vim_strnsave(*fnamep, *fnamelen); *usedlen = (size_t)(p + 1 - src); s = do_string_sub(str, pat, sub, NULL, flags); *fnamep = s; diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index ed01e8a8b0..16eb6f8898 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -6553,7 +6553,7 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr) } if (prevlen == 0) { assert(len < INT_MAX); - s = vim_strnsave(start, (int)len); + s = vim_strnsave(start, len); } else { /* Change "prev" buffer to be the right size. This way * the bytes are only copied once, and very long lines are @@ -10855,7 +10855,7 @@ static void f_trim(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } } - rettv->vval.v_string = vim_strnsave(head, (int)(tail - head)); + rettv->vval.v_string = vim_strnsave(head, tail - head); } /* diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 4e8b98d723..70c998ef39 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -2297,9 +2297,9 @@ void ex_function(exarg_T *eap) // Ignore leading white space. p = skipwhite(p + 4); heredoc_trimmed = - vim_strnsave(theline, (int)(skipwhite(theline) - theline)); + vim_strnsave(theline, skipwhite(theline) - theline); } - skip_until = vim_strnsave(p, (int)(skiptowhite(p) - p)); + skip_until = vim_strnsave(p, skiptowhite(p) - p); do_concat = false; is_heredoc = true; } diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 6e08378ad4..a7d97c904b 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -2323,7 +2323,7 @@ int do_ecmd( // Existing memfile. oldbuf = true; set_bufref(&bufref, buf); - (void)buf_check_timestamp(buf, false); + (void)buf_check_timestamp(buf); // Check if autocommands made buffer invalid or changed the current // buffer. if (!bufref_valid(&bufref) || curbuf != old_curbuf.br_buf) { @@ -2796,9 +2796,10 @@ void ex_append(exarg_T *eap) p = vim_strchr(eap->nextcmd, NL); if (p == NULL) p = eap->nextcmd + STRLEN(eap->nextcmd); - theline = vim_strnsave(eap->nextcmd, (int)(p - eap->nextcmd)); - if (*p != NUL) - ++p; + theline = vim_strnsave(eap->nextcmd, p - eap->nextcmd); + if (*p != NUL) { + p++; + } eap->nextcmd = p; } else { // Set State to avoid the cursor shape to be set to INSERT mode diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 3b9c44c3cd..bde584d27e 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -3392,7 +3392,7 @@ void ex_checktime(exarg_T *eap) } else { buf = buflist_findnr((int)eap->line2); if (buf != NULL) { // cannot happen? - (void)buf_check_timestamp(buf, false); + (void)buf_check_timestamp(buf); } } no_check_timestamps = save_no_check_timestamps; @@ -3790,6 +3790,14 @@ void ex_drop(exarg_T *eap) if (wp->w_buffer == buf) { goto_tabpage_win(tp, wp); curwin->w_arg_idx = 0; + if (!bufIsChanged(curbuf)) { + const int save_ar = curbuf->b_p_ar; + + // reload the file if it is newer + curbuf->b_p_ar = 1; + buf_check_timestamp(curbuf); + curbuf->b_p_ar = save_ar; + } return; } } diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 601f4aab38..3fc02e0693 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -2979,6 +2979,15 @@ const char * set_one_cmd_context( const char *arg = (const char *)skipwhite((const char_u *)p); + // Skip over ++argopt argument + if ((ea.argt & ARGOPT) && *arg != NUL && strncmp(arg, "++", 2) == 0) { + p = arg; + while (*p && !ascii_isspace(*p)) { + MB_PTR_ADV(p); + } + arg = (const char *)skipwhite((const char_u *)p); + } + if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update) { if (*arg == '>') { // Append. if (*++arg == '>') { @@ -4979,7 +4988,6 @@ static int uc_add_command(char_u *name, size_t name_len, char_u *rep, FUNC_ATTR_NONNULL_ARG(1, 3) { ucmd_T *cmd = NULL; - char_u *p; int i; int cmp = 1; char_u *rep_buf = NULL; @@ -5039,7 +5047,7 @@ static int uc_add_command(char_u *name, size_t name_len, char_u *rep, if (cmp != 0) { ga_grow(gap, 1); - p = vim_strnsave(name, (int)name_len); + char_u *const p = vim_strnsave(name, name_len); cmd = USER_CMD_GA(gap, i); memmove(cmd + 1, cmd, (gap->ga_len - i) * sizeof(ucmd_T)); @@ -6188,8 +6196,9 @@ int parse_compl_arg(const char_u *value, int vallen, int *complp, return FAIL; } - if (arg != NULL) - *compl_arg = vim_strnsave(arg, (int)arglen); + if (arg != NULL) { + *compl_arg = vim_strnsave(arg, arglen); + } return OK; } @@ -9283,7 +9292,7 @@ static void ex_match(exarg_T *eap) } else { p = skiptowhite(eap->arg); if (!eap->skip) { - g = vim_strnsave(eap->arg, (int)(p - eap->arg)); + g = vim_strnsave(eap->arg, p - eap->arg); } p = skipwhite(p); if (*p == NUL) { diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 5e3cdd5da2..0bc52f1e97 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1082,6 +1082,7 @@ static int command_line_execute(VimState *state, int key) if (s->c == K_DOWN && ccline.cmdpos > 0 && ccline.cmdbuff[ccline.cmdpos - 1] == '.') { s->c = (int)p_wc; + KeyTyped = true; // in case the key was mapped } else if (s->c == K_UP) { // Hitting <Up>: Remove one submenu name in front of the // cursor @@ -1112,6 +1113,7 @@ static int command_line_execute(VimState *state, int key) cmdline_del(i); } s->c = (int)p_wc; + KeyTyped = true; // in case the key was mapped s->xpc.xp_context = EXPAND_NOTHING; } } @@ -1134,6 +1136,7 @@ static int command_line_execute(VimState *state, int key) || ccline.cmdbuff[ccline.cmdpos - 3] != '.')) { // go down a directory s->c = (int)p_wc; + KeyTyped = true; // in case the key was mapped } else if (STRNCMP(s->xpc.xp_pattern, upseg + 1, 3) == 0 && s->c == K_DOWN) { // If in a direct ancestor, strip off one ../ to go down @@ -1154,6 +1157,7 @@ static int command_line_execute(VimState *state, int key) && (vim_ispathsep(ccline.cmdbuff[j - 3]) || j == i + 2)) { cmdline_del(j - 2); s->c = (int)p_wc; + KeyTyped = true; // in case the key was mapped } } else if (s->c == K_UP) { // go up a directory @@ -2251,7 +2255,9 @@ static int command_line_changed(CommandLineState *s) close_preview_windows(); update_screen(SOME_VALID); // Clear 'inccommand' preview. } else { - may_do_incsearch_highlighting(s->firstc, s->count, &s->is_state); + if (s->xpc.xp_context == EXPAND_NOTHING) { + may_do_incsearch_highlighting(s->firstc, s->count, &s->is_state); + } } if (cmdmsg_rl || (p_arshape && !p_tbidi)) { diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 936a9d1397..e1e34bf24a 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -2032,7 +2032,7 @@ static char_u *next_fenc(char_u **pp, bool *alloced) r = enc_canonize(*pp); *pp += STRLEN(*pp); } else { - r = vim_strnsave(*pp, (int)(p - *pp)); + r = vim_strnsave(*pp, p - *pp); *pp = p + 1; p = enc_canonize(r); xfree(r); @@ -4675,7 +4675,6 @@ check_timestamps( ) { int didit = 0; - int n; /* Don't check timestamps while system() or another low-level function may * cause us to lose and gain focus. */ @@ -4703,7 +4702,7 @@ check_timestamps( if (buf->b_nwindows > 0) { bufref_T bufref; set_bufref(&bufref, buf); - n = buf_check_timestamp(buf, focus); + const int n = buf_check_timestamp(buf); if (didit < n) { didit = n; } @@ -4773,11 +4772,7 @@ static int move_lines(buf_T *frombuf, buf_T *tobuf) * return 2 if a message has been displayed. * return 0 otherwise. */ -int -buf_check_timestamp( - buf_T *buf, - int focus /* called for GUI focus event */ -) +int buf_check_timestamp(buf_T *buf) FUNC_ATTR_NONNULL_ALL { int retval = 0; diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 70225484ec..31dc6b3649 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -975,9 +975,9 @@ void ml_recover(bool checkext) if (b0p->b0_flags & B0_HAS_FENC) { int fnsize = B0_FNAME_SIZE_NOCRYPT; - for (p = b0p->b0_fname + fnsize; p > b0p->b0_fname && p[-1] != NUL; --p) - ; - b0_fenc = vim_strnsave(p, (int)(b0p->b0_fname + fnsize - p)); + for (p = b0p->b0_fname + fnsize; p > b0p->b0_fname && p[-1] != NUL; p--) { + } + b0_fenc = vim_strnsave(p, b0p->b0_fname + fnsize - p); } mf_put(mfp, hp, false, false); /* release block 0 */ diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index fb08cd2727..a2589ac431 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -3724,8 +3724,7 @@ static long regtry(bt_regprog_T *prog, } else { if (reg_startzp[i] != NULL && reg_endzp[i] != NULL) re_extmatch_out->matches[i] = - vim_strnsave(reg_startzp[i], - (int)(reg_endzp[i] - reg_startzp[i])); + vim_strnsave(reg_startzp[i], reg_endzp[i] - reg_startzp[i]); } } } @@ -6565,7 +6564,7 @@ static int fill_submatch_list(int argc FUNC_ATTR_UNUSED, typval_T *argv, if (s == NULL || rsm.sm_match->endp[i] == NULL) { s = NULL; } else { - s = vim_strnsave(s, (int)(rsm.sm_match->endp[i] - s)); + s = vim_strnsave(s, rsm.sm_match->endp[i] - s); } TV_LIST_ITEM_TV(li)->v_type = VAR_STRING; TV_LIST_ITEM_TV(li)->vval.v_string = s; @@ -7084,7 +7083,7 @@ char_u *reg_submatch(int no) if (s == NULL || rsm.sm_match->endp[no] == NULL) { retval = NULL; } else { - retval = vim_strnsave(s, (int)(rsm.sm_match->endp[no] - s)); + retval = vim_strnsave(s, rsm.sm_match->endp[no] - s); } } diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index d38719f396..8b5ee59d40 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -6480,8 +6480,7 @@ static long nfa_regtry(nfa_regprog_T *prog, if (lpos->start != NULL && lpos->end != NULL) re_extmatch_out->matches[i] = - vim_strnsave(lpos->start, - (int)(lpos->end - lpos->start)); + vim_strnsave(lpos->start, lpos->end - lpos->start); } } } diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index e91d560284..4d88df5a3a 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -4186,10 +4186,10 @@ get_syn_options( arg = skiptowhite(arg); if (gname_start == arg) return NULL; - gname = vim_strnsave(gname_start, (int)(arg - gname_start)); - if (STRCMP(gname, "NONE") == 0) + gname = vim_strnsave(gname_start, arg - gname_start); + if (STRCMP(gname, "NONE") == 0) { *opt->sync_idx = NONE_IDX; - else { + } else { syn_id = syn_name2id(gname); int i; for (i = curwin->w_s->b_syn_patterns.ga_len; --i >= 0; ) @@ -4587,7 +4587,7 @@ syn_cmd_region( while (*key_end && !ascii_iswhite(*key_end) && *key_end != '=') ++key_end; xfree(key); - key = vim_strnsave_up(rest, (int)(key_end - rest)); + key = vim_strnsave_up(rest, key_end - rest); if (STRCMP(key, "MATCHGROUP") == 0) { item = ITEM_MATCHGROUP; } else if (STRCMP(key, "START") == 0) { @@ -5047,8 +5047,8 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci) EMSG2(_("E401: Pattern delimiter not found: %s"), arg); return NULL; } - /* store the pattern and compiled regexp program */ - ci->sp_pattern = vim_strnsave(arg + 1, (int)(end - arg - 1)); + // store the pattern and compiled regexp program + ci->sp_pattern = vim_strnsave(arg + 1, end - arg - 1); /* Make 'cpoptions' empty, to avoid the 'l' flag */ cpo_save = p_cpo; @@ -5136,7 +5136,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing) arg_end = skiptowhite(arg_start); next_arg = skipwhite(arg_end); xfree(key); - key = vim_strnsave_up(arg_start, (int)(arg_end - arg_start)); + key = vim_strnsave_up(arg_start, arg_end - arg_start); if (STRCMP(key, "CCOMMENT") == 0) { if (!eap->skip) curwin->w_s->b_syn_sync_flags |= SF_CCOMMENT; @@ -5195,7 +5195,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing) if (!eap->skip) { /* store the pattern and compiled regexp program */ curwin->w_s->b_syn_linecont_pat = - vim_strnsave(next_arg + 1, (int)(arg_end - next_arg - 1)); + vim_strnsave(next_arg + 1, arg_end - next_arg - 1); curwin->w_s->b_syn_linecont_ic = curwin->w_s->b_syn_ic; /* Make 'cpoptions' empty, to avoid the 'l' flag */ @@ -5555,18 +5555,17 @@ void ex_syntax(exarg_T *eap) { char_u *arg = eap->arg; char_u *subcmd_end; - char_u *subcmd_name; - int i; syn_cmdlinep = eap->cmdlinep; - /* isolate subcommand name */ - for (subcmd_end = arg; ASCII_ISALPHA(*subcmd_end); ++subcmd_end) - ; - subcmd_name = vim_strnsave(arg, (int)(subcmd_end - arg)); - if (eap->skip) /* skip error messages for all subcommands */ - ++emsg_skip; - for (i = 0;; ++i) { + // isolate subcommand name + for (subcmd_end = arg; ASCII_ISALPHA(*subcmd_end); subcmd_end++) { + } + char_u *const subcmd_name = vim_strnsave(arg, subcmd_end - arg); + if (eap->skip) { // skip error messages for all subcommands + emsg_skip++; + } + for (int i = 0;; i++) { if (subcommands[i].name == NULL) { EMSG2(_("E410: Invalid :syntax subcommand: %s"), subcmd_name); break; @@ -6719,7 +6718,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) } xfree(key); key = (char *)vim_strnsave_up((const char_u *)key_start, - (int)(linep - key_start)); + linep - key_start); linep = (const char *)skipwhite((const char_u *)linep); if (strcmp(key, "NONE") == 0) { diff --git a/src/nvim/testdir/test_clientserver.vim b/src/nvim/testdir/test_clientserver.vim index 3377f86126..53704bd094 100644 --- a/src/nvim/testdir/test_clientserver.vim +++ b/src/nvim/testdir/test_clientserver.vim @@ -61,6 +61,15 @@ func Test_client_server() call assert_fails('call remote_send("XXX", ":let testvar = ''yes''\<CR>")', 'E241') + call writefile(['one'], 'Xclientfile') + let cmd = GetVimProg() .. ' --servername ' .. name .. ' --remote Xclientfile' + call system(cmd) + call WaitForAssert({-> assert_equal('Xclientfile', remote_expr(name, "bufname()", "", 2))}) + call WaitForAssert({-> assert_equal('one', remote_expr(name, "getline(1)", "", 2))}) + call writefile(['one', 'two'], 'Xclientfile') + call system(cmd) + call WaitForAssert({-> assert_equal('two', remote_expr(name, "getline(2)", "", 2))}) + " Expression evaluated locally. if v:servername == '' call remote_startserver('MYSELF') diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 8fc3361b79..bb0cae4819 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -51,6 +51,19 @@ func Test_complete_wildmenu() call feedkeys(":e Xdir1/\<Tab>\<Down>\<Up>\<Right>\<CR>", 'tx') call assert_equal('testfile1', getline(1)) + + " <C-J>/<C-K> mappings to go up/down directories when 'wildcharm' is + " different than 'wildchar'. + set wildcharm=<C-Z> + cnoremap <C-J> <Down><C-Z> + cnoremap <C-K> <Up><C-Z> + call feedkeys(":e Xdir1/\<Tab>\<C-J>\<CR>", 'tx') + call assert_equal('testfile3', getline(1)) + call feedkeys(":e Xdir1/\<Tab>\<C-J>\<C-K>\<CR>", 'tx') + call assert_equal('testfile1', getline(1)) + set wildcharm=0 + cunmap <C-J> + cunmap <C-K> + " cleanup %bwipe call delete('Xdir1/Xdir2/Xtestfile4') @@ -62,6 +75,33 @@ func Test_complete_wildmenu() set nowildmenu endfunc +func Test_wildmenu_screendump() + CheckScreendump + + let lines =<< trim [SCRIPT] + set wildmenu hlsearch + [SCRIPT] + call writefile(lines, 'XTest_wildmenu') + + let buf = RunVimInTerminal('-S XTest_wildmenu', {'rows': 8}) + call term_sendkeys(buf, ":vim\<Tab>") + call VerifyScreenDump(buf, 'Test_wildmenu_1', {}) + + call term_sendkeys(buf, "\<Tab>") + call VerifyScreenDump(buf, 'Test_wildmenu_2', {}) + + call term_sendkeys(buf, "\<Tab>") + call VerifyScreenDump(buf, 'Test_wildmenu_3', {}) + + call term_sendkeys(buf, "\<Tab>") + call VerifyScreenDump(buf, 'Test_wildmenu_4', {}) + call term_sendkeys(buf, "\<Esc>") + + " clean up + call StopVimInTerminal(buf) + call delete('XTest_wildmenu') +endfunc + func Test_map_completion() if !has('cmdline_compl') return @@ -837,6 +877,36 @@ func Test_cmdwin_cedit() delfunc CmdWinType endfunc +func Test_cmdwin_restore() + CheckScreendump + + let lines =<< trim [SCRIPT] + call setline(1, range(30)) + 2split + [SCRIPT] + call writefile(lines, 'XTest_restore') + + let buf = RunVimInTerminal('-S XTest_restore', {'rows': 12}) + call term_wait(buf, 100) + call term_sendkeys(buf, "q:") + call VerifyScreenDump(buf, 'Test_cmdwin_restore_1', {}) + + " normal restore + call term_sendkeys(buf, ":q\<CR>") + call VerifyScreenDump(buf, 'Test_cmdwin_restore_2', {}) + + " restore after setting 'lines' with one window + call term_sendkeys(buf, ":close\<CR>") + call term_sendkeys(buf, "q:") + call term_sendkeys(buf, ":set lines=18\<CR>") + call term_sendkeys(buf, ":q\<CR>") + call VerifyScreenDump(buf, 'Test_cmdwin_restore_3', {}) + + " clean up + call StopVimInTerminal(buf) + call delete('XTest_restore') +endfunc + func Test_buffers_lastused() " check that buffers are sorted by time when wildmode has lastused edit bufc " oldest @@ -912,5 +982,23 @@ func Test_zero_line_search() q! endfunc +func Test_read_shellcmd() + CheckUnix + if executable('ls') + " There should be ls in the $PATH + call feedkeys(":r! l\<c-a>\<c-b>\"\<cr>", 'tx') + call assert_match('^"r! .*\<ls\>', @:) + endif + + if executable('rm') + call feedkeys(":r! ++enc=utf-8 r\<c-a>\<c-b>\"\<cr>", 'tx') + call assert_notmatch('^"r!.*\<runtest.vim\>', @:) + call assert_match('^"r!.*\<rm\>', @:) + + call feedkeys(":r ++enc=utf-8 !rm\<c-a>\<c-b>\"\<cr>", 'tx') + call assert_notmatch('^"r.*\<runtest.vim\>', @:) + call assert_match('^"r ++enc\S\+ !.*\<rm\>', @:) + endif +endfunc " vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/window.c b/src/nvim/window.c index 6ecfd9ab64..2dcce2d8cb 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -5013,7 +5013,10 @@ void win_size_save(garray_T *gap) { ga_init(gap, (int)sizeof(int), 1); - ga_grow(gap, win_count() * 2); + ga_grow(gap, win_count() * 2 + 1); + // first entry is value of 'lines' + ((int *)gap->ga_data)[gap->ga_len++] = Rows; + FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { ((int *)gap->ga_data)[gap->ga_len++] = wp->w_width + wp->w_vsep_width; @@ -5021,18 +5024,18 @@ void win_size_save(garray_T *gap) } } -/* - * Restore window sizes, but only if the number of windows is still the same. - * Does not free the growarray. - */ +// Restore window sizes, but only if the number of windows is still the same +// and 'lines' didn't change. +// Does not free the growarray. void win_size_restore(garray_T *gap) + FUNC_ATTR_NONNULL_ALL { - if (win_count() * 2 == gap->ga_len) { - /* The order matters, because frames contain other frames, but it's - * difficult to get right. The easy way out is to do it twice. */ - for (int j = 0; j < 2; ++j) - { - int i = 0; + if (win_count() * 2 + 1 == gap->ga_len + && ((int *)gap->ga_data)[0] == Rows) { + // The order matters, because frames contain other frames, but it's + // difficult to get right. The easy way out is to do it twice. + for (int j = 0; j < 2; j++) { + int i = 1; FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { int width = ((int *)gap->ga_data)[i++]; int height = ((int *)gap->ga_data)[i++]; |