From 09232958ff9c7d4737701160549c8d64a0f92856 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 6 Oct 2019 20:52:30 -0400 Subject: vim-patch:8.1.2120: some MB_ macros are more complicated than necessary Problem: Some MB_ macros are more complicated than necessary. (Dominique Pelle) Solution: Simplify the macros. Expand inline. https://github.com/vim/vim/commit/1614a14901558ca091329315d14a7d5e1b53aa47 --- src/nvim/ex_getln.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 3f7bc45c2e..d0af8a0fdf 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2320,7 +2320,7 @@ redraw: } while (++vcol % 8); p++; } else { - len = MB_PTR2LEN(p); + len = utfc_ptr2len(p); msg_outtrans_len(p, len); vcol += ptr2cells(p); p += len; -- cgit From 0586a4b512b2495d32f20c46946d35a0d403bd52 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Mon, 23 Sep 2019 21:19:26 +0200 Subject: vim-patch:8.1.1588: in :let-heredoc line continuation is recognized Problem: In :let-heredoc line continuation is recognized. Solution: Do not consume line continuation. (Ozaki Kiichi, closes vim/vim#4580) https://github.com/vim/vim/commit/e96a2498f9a2d3e93ac07431f6d4afd77f30afdf --- src/nvim/ex_getln.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index d0af8a0fdf..5235b9e648 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1991,7 +1991,8 @@ char_u * getcmdline ( int firstc, long count, // only used for incremental search - int indent // indent for inside conditionals + int indent, // indent for inside conditionals + bool do_concat // unused ) { // Be prepared for situations where cmdline can be invoked recursively. @@ -2167,17 +2168,18 @@ static void correct_screencol(int idx, int cells, int *col) * Get an Ex command line for the ":" command. */ char_u * -getexline ( - int c, /* normally ':', NUL for ":append" */ +getexline( + int c, // normally ':', NUL for ":append" void *cookie, - int indent /* indent for inside conditionals */ + int indent, // indent for inside conditionals + bool do_concat ) { /* When executing a register, remove ':' that's in front of each line. */ if (exec_from_reg && vpeekc() == ':') (void)vgetc(); - return getcmdline(c, 1L, indent); + return getcmdline(c, 1L, indent, do_concat); } /* @@ -2187,11 +2189,12 @@ getexline ( * Returns a string in allocated memory or NULL. */ char_u * -getexmodeline ( - int promptc, /* normally ':', NUL for ":append" and '?' for - :s prompt */ +getexmodeline( + int promptc, // normally ':', NUL for ":append" and '?' + // for :s prompt void *cookie, - int indent /* indent for inside conditionals */ + int indent, // indent for inside conditionals + bool do_concat ) { garray_T line_ga; @@ -6308,7 +6311,7 @@ char *script_get(exarg_T *const eap, size_t *const lenp) for (;;) { char *const theline = (char *)eap->getline( eap->cstack->cs_looplevel > 0 ? -1 : - NUL, eap->cookie, 0); + NUL, eap->cookie, 0, true); if (theline == NULL || strcmp(end_pattern, theline) == 0) { xfree(theline); -- cgit From 034077ed1c1fa71aa15829ed2dfb27de4a5e5359 Mon Sep 17 00:00:00 2001 From: Jaehwang Jerry Jung Date: Fri, 25 Oct 2019 19:54:53 +0900 Subject: vim-patch:8.1.2173: searchit() has too many arguments Problem: Searchit() has too many arguments. Solution: Move optional arguments to a struct. Add the "wrapped" argument. https://github.com/vim/vim/commit/92ea26b925a0835badb0af2d5887238a4198cabb --- src/nvim/ex_getln.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 5235b9e648..f2665ca0b5 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1075,7 +1075,7 @@ static void command_line_next_incsearch(CommandLineState *s, bool next_match) int found = searchit(curwin, curbuf, &t, NULL, next_match ? FORWARD : BACKWARD, pat, s->count, search_flags, - RE_SEARCH, 0, NULL, NULL); + RE_SEARCH, NULL); emsg_off--; ui_busy_stop(); if (found) { @@ -1818,6 +1818,7 @@ static int command_line_changed(CommandLineState *s) if (p_is && !cmd_silent && (s->firstc == '/' || s->firstc == '?')) { pos_T end_pos; proftime_T tm; + searchit_arg_T sia; // if there is a character waiting, search and redraw later if (char_avail()) { @@ -1844,8 +1845,10 @@ static int command_line_changed(CommandLineState *s) if (!p_hls) { search_flags += SEARCH_KEEP; } + memset(&sia, 0, sizeof(sia)); + sia.sa_tm = &tm; i = do_search(NULL, s->firstc, ccline.cmdbuff, s->count, - search_flags, &tm, NULL); + search_flags, &sia); emsg_off--; // if interrupted while searching, behave like it failed if (got_int) { -- cgit From d04ab11f24521e60278a0daed9a7d5abeeaf6f4f Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Tue, 29 Oct 2019 22:32:25 +0000 Subject: Prevent prompts during inccommand previews For example, "Backwards range given, OK to swap (y/n)?" on each keypress. --- src/nvim/ex_getln.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index f2665ca0b5..9e2671ca5e 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1927,7 +1927,9 @@ static int command_line_changed(CommandLineState *s) // - Immediately undo the effects. State |= CMDPREVIEW; emsg_silent++; // Block error reporting as the command may be incomplete + msg_silent++; // Block messages, namely ones that prompt do_cmdline(ccline.cmdbuff, NULL, NULL, DOCMD_KEEPLINE|DOCMD_NOWAIT); + msg_silent--; // Unblock messages emsg_silent--; // Unblock error reporting // Restore the window "view". -- cgit From 226ad89a2cf46b9a11a38b3236e23bd3e4c9b94a Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 25 Nov 2019 00:34:52 -0500 Subject: vim-patch:8.1.0223: completing shell command finds sub-directories in $PATH Problem: Completing shell command finds sub-directories in $PATH. Solution: Remove EW_DIR when completing an item in $PATH. (Jason Franklin) https://github.com/vim/vim/commit/6ab9e429da18f4d784222a9f7dfafb7c0218b7eb --- src/nvim/ex_getln.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 9e2671ca5e..7948da5e6b 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -5008,19 +5008,24 @@ static void expand_shellcmd(char_u *filepat, int *num_file, char_u ***file, hashtab_T found_ht; hash_init(&found_ht); for (s = path; ; s = e) { + e = vim_strchr(s, ENV_SEPCHAR); + if (e == NULL) { + e = s + STRLEN(s); + } + if (*s == NUL) { if (did_curdir) { break; } // Find directories in the current directory, path is empty. did_curdir = true; - } else if (*s == '.') { + flags |= EW_DIR; + } else if (STRNCMP(s, ".", e - s) == 0) { did_curdir = true; - } - - e = vim_strchr(s, ENV_SEPCHAR); - if (e == NULL) { - e = s + STRLEN(s); + flags |= EW_DIR; + } else { + // Do not match directories inside a $PATH item. + flags &= ~EW_DIR; } l = (size_t)(e - s); -- cgit From f33371c03f526ecbe2d6a1bec744fa37c1b2640c Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 29 Nov 2019 18:51:25 +0100 Subject: vim-patch:8.1.2017: cannot execute commands after closing cmdline window #11479 Problem: Cannot execute commands after closing the cmdline window. Solution: Also trigger BufEnter and WinEnter. (closes vim/vim#4762) https://github.com/vim/vim/commit/96e38a86a710fb6daec4550ac1667f019dc3a40e Fixes https://github.com/neovim/neovim/issues/11279. --- src/nvim/ex_getln.c | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 7948da5e6b..73353f84cf 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -6078,12 +6078,9 @@ static int open_cmdwin(void) set_bufref(&old_curbuf, curbuf); - /* Save current window sizes. */ + // Save current window sizes. win_size_save(&winsizes); - /* Don't execute autocommands while creating the window. */ - block_autocmds(); - // When using completion in Insert mode with = one can open the // command line window, but we don't want the popup menu then. pum_undisplay(true); @@ -6092,10 +6089,9 @@ static int open_cmdwin(void) cmdmod.tab = 0; cmdmod.noswapfile = 1; - /* Create a window for the command-line buffer. */ + // Create a window for the command-line buffer. if (win_split((int)p_cwh, WSP_BOT) == FAIL) { beep_flush(); - unblock_autocmds(); return K_IGNORE; } cmdwin_type = get_cmdline_type(); @@ -6110,13 +6106,11 @@ static int open_cmdwin(void) curbuf->b_p_ma = true; curwin->w_p_fen = false; - // Do execute autocommands for setting the filetype (load syntax). - unblock_autocmds(); - // But don't allow switching to another buffer. + // Don't allow switching to another buffer. curbuf_lock++; - /* Showing the prompt may have set need_wait_return, reset it. */ - need_wait_return = FALSE; + // Showing the prompt may have set need_wait_return, reset it. + need_wait_return = false; const int histtype = hist_char2type(cmdwin_type); if (histtype == HIST_CMD || histtype == HIST_DEBUG) { @@ -6128,11 +6122,11 @@ static int open_cmdwin(void) } curbuf_lock--; - /* Reset 'textwidth' after setting 'filetype' (the Vim filetype plugin - * sets 'textwidth' to 78). */ + // Reset 'textwidth' after setting 'filetype' (the Vim filetype plugin + // sets 'textwidth' to 78). curbuf->b_p_tw = 0; - /* Fill the buffer with the history. */ + // Fill the buffer with the history. init_history(); if (hislen > 0 && histtype != HIST_INVALID) { i = hisidx[histtype]; @@ -6173,9 +6167,10 @@ static int open_cmdwin(void) // Trigger CmdwinEnter autocommands. typestr[0] = (char_u)cmdwin_type; typestr[1] = NUL; - apply_autocmds(EVENT_CMDWINENTER, typestr, typestr, FALSE, curbuf); - if (restart_edit != 0) /* autocmd with ":startinsert" */ + apply_autocmds(EVENT_CMDWINENTER, typestr, typestr, false, curbuf); + if (restart_edit != 0) { // autocmd with ":startinsert" stuffcharReadbuff(K_NOP); + } i = RedrawingDisabled; RedrawingDisabled = 0; @@ -6192,10 +6187,10 @@ static int open_cmdwin(void) const bool save_KeyTyped = KeyTyped; - /* Trigger CmdwinLeave autocommands. */ - apply_autocmds(EVENT_CMDWINLEAVE, typestr, typestr, FALSE, curbuf); + // Trigger CmdwinLeave autocommands. + apply_autocmds(EVENT_CMDWINLEAVE, typestr, typestr, false, curbuf); - /* Restore KeyTyped in case it is modified by autocommands */ + // Restore KeyTyped in case it is modified by autocommands KeyTyped = save_KeyTyped; // Restore the command line info. @@ -6254,9 +6249,7 @@ static int open_cmdwin(void) } } - /* Don't execute autocommands while deleting the window. */ - block_autocmds(); - // Avoid command-line window first character being concealed + // Avoid command-line window first character being concealed. curwin->w_p_cole = 0; wp = curwin; set_bufref(&bufref, curbuf); @@ -6269,10 +6262,8 @@ static int open_cmdwin(void) close_buffer(NULL, bufref.br_buf, DOBUF_WIPE, false); } - /* Restore window sizes. */ + // Restore window sizes. win_size_restore(&winsizes); - - unblock_autocmds(); } ga_clear(&winsizes); -- cgit From ed424655bef3169dc5452c5a8212e250dc483f9e Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 5 Dec 2019 02:04:19 -0500 Subject: vim-patch:8.1.2385: open cmdline window with feedkeys() #11516 Problem: Opening cmdline window with feedkeys() does not work. (Yegappan Lakshmanan) Solution: Recognize K_CMDWIN also when ex_normal_busy is set. https://github.com/vim/vim/commit/85db5475982e166ec5bb1c8c9a5c8bf062d49ed1 --- src/nvim/ex_getln.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 73353f84cf..8065d764b9 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -878,7 +878,9 @@ static int command_line_execute(VimState *state, int key) } if (s->c == cedit_key || s->c == K_CMDWIN) { - if (ex_normal_busy == 0 && got_int == false) { + // TODO(vim): why is ex_normal_busy checked here? + if ((s->c == K_CMDWIN || ex_normal_busy == 0) + && got_int == false) { // Open a window to edit the command line (and history). s->c = open_cmdwin(); s->some_key_typed = true; -- cgit From bc8da6cdbe4e300344e45dbc2eb5b22a7afc9e89 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 22 Dec 2019 11:24:48 -0500 Subject: vim-patch:8.0.1767: with 'incsearch' text may jump up and down Problem: With 'incsearch' text may jump up and down. () Solution: Besides w_botline also save and restore w_empty_rows. (closes # 2530) https://github.com/vim/vim/commit/9d34d90210ba52ebaf45973282e5921f5af364c7 --- src/nvim/ex_getln.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 8065d764b9..35159060b8 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -161,6 +161,8 @@ typedef struct command_line_state { int init_topfill; linenr_T old_botline; linenr_T init_botline; + int old_empty_rows; + int init_empty_rows; pos_T match_start; pos_T match_end; int did_incsearch; @@ -253,6 +255,7 @@ static uint8_t *command_line_enter(int firstc, long count, int indent) s->init_topline = curwin->w_topline; s->init_topfill = curwin->w_topfill; s->init_botline = curwin->w_botline; + s->init_empty_rows = curwin->w_empty_rows; if (s->firstc == -1) { s->firstc = NUL; @@ -275,6 +278,7 @@ static uint8_t *command_line_enter(int firstc, long count, int indent) s->old_topline = curwin->w_topline; s->old_topfill = curwin->w_topfill; s->old_botline = curwin->w_botline; + s->old_empty_rows = curwin->w_empty_rows; assert(indent >= 0); @@ -449,6 +453,7 @@ static uint8_t *command_line_enter(int firstc, long count, int indent) curwin->w_topline = s->old_topline; curwin->w_topfill = s->old_topfill; curwin->w_botline = s->old_botline; + curwin->w_empty_rows = s->old_empty_rows; highlight_match = false; validate_cursor(); // needed for TAB redraw_all_later(SOME_VALID); @@ -1118,6 +1123,7 @@ static void command_line_next_incsearch(CommandLineState *s, bool next_match) s->old_topline = curwin->w_topline; s->old_topfill = curwin->w_topfill; s->old_botline = curwin->w_botline; + s->old_empty_rows = curwin->w_empty_rows; update_screen(NOT_VALID); redrawcmdline(); } else { @@ -1243,6 +1249,7 @@ static int command_line_handle_key(CommandLineState *s) s->old_topline = s->init_topline; s->old_topfill = s->init_topfill; s->old_botline = s->init_botline; + s->old_empty_rows = s->init_empty_rows; } redrawcmd(); } else if (ccline.cmdlen == 0 && s->c != Ctrl_W @@ -1876,6 +1883,7 @@ static int command_line_changed(CommandLineState *s) curwin->w_topline = s->old_topline; curwin->w_topfill = s->old_topfill; curwin->w_botline = s->old_botline; + curwin->w_empty_rows = s->old_empty_rows; changed_cline_bef_curs(); update_topline(); -- cgit From 251177b63b591018cf865e809692ba6eb18f7a5c Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 25 Dec 2019 18:32:29 -0500 Subject: ex_getln: fix pvs/v781 --- src/nvim/ex_getln.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 35159060b8..e5f5e5ad87 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -3575,7 +3575,7 @@ static int ccheck_abbr(int c) // Do not consider '<,'> be part of the mapping, skip leading whitespace. // Actually accepts any mark. - while (ascii_iswhite(ccline.cmdbuff[spos]) && spos < ccline.cmdlen) { + while (spos < ccline.cmdlen && ascii_iswhite(ccline.cmdbuff[spos])) { spos++; } if (ccline.cmdlen - spos > 5 -- cgit From 5e1cad6d3378398c059e1a7144e1310b7bcb2398 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 30 Dec 2019 00:56:57 -0500 Subject: vim-patch:8.0.1356: using simalt in a GUIEnter autocommand inserts characters Problem: Using simalt in a GUIEnter autocommand inserts strange characters. (Chih-Long Chang) Solution: Ignore K_NOP in Insert mode. (closes vim/vim#2379) https://github.com/vim/vim/commit/c5aa55db7e5bc791f99fb15b0f4be0d5dd166f62 --- src/nvim/ex_getln.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index e5f5e5ad87..c09a3c08ef 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -536,7 +536,7 @@ static int command_line_check(VimState *state) static int command_line_execute(VimState *state, int key) { - if (key == K_IGNORE) { + if (key == K_IGNORE || key == K_NOP) { return -1; // get another key } -- cgit From 3d6cca5a9d7cc9c13af631d2c6d652096203ce13 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 7 Jan 2020 23:20:35 -0500 Subject: vim-patch:8.2.0099: use of NULL pointer when out of memory Problem: Use of NULL pointer when out of memory. Solution: Check for NULL pointer. (Dominique Pelle, closes vim/vim#5449) https://github.com/vim/vim/commit/8b7aa2f9b238df916c161cdacda032c25d72a0ae --- src/nvim/ex_getln.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index c09a3c08ef..b2dc90f3fb 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -4715,8 +4715,7 @@ ExpandFromContext ( int free_pat = FALSE; int i; - /* for ":set path=" and ":set tags=" halve backslashes for escaped - * space */ + // for ":set path=" and ":set tags=" halve backslashes for escaped space if (xp->xp_backslash != XP_BS_NONE) { free_pat = TRUE; pat = vim_strsave(pat); @@ -4984,8 +4983,7 @@ static void expand_shellcmd(char_u *filepat, int *num_file, char_u ***file, int ret; bool did_curdir = false; - /* for ":set path=" and ":set tags=" halve backslashes for escaped - * space */ + // for ":set path=" and ":set tags=" halve backslashes for escaped space pat = vim_strsave(filepat); for (i = 0; pat[i]; ++i) if (pat[i] == '\\' && pat[i + 1] == ' ') -- cgit From 45759e44f9cff9deef1538933fad3e42f94d5930 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 8 Jan 2020 01:08:55 -0500 Subject: Remove (void) hacks, Mark unused attrs --- src/nvim/ex_getln.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index b2dc90f3fb..2578d1837a 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2007,7 +2007,7 @@ getcmdline ( int firstc, long count, // only used for incremental search int indent, // indent for inside conditionals - bool do_concat // unused + bool do_concat FUNC_ATTR_UNUSED ) { // Be prepared for situations where cmdline can be invoked recursively. -- cgit From 462ee281b779b0f2189132a75dccebeb38a62042 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 11 Jan 2020 16:21:21 -0500 Subject: vim-patch:8.0.1769: refactor save/restore of viewstate #11701 Problem: Repeated saving and restoring viewstate for 'incsearch'. Solution: Use a structure. https://github.com/vim/vim/commit/9b25af36204c0511eab08d621688f0f2008fc68e --- src/nvim/ex_getln.c | 111 +++++++++++++++++++++++----------------------------- 1 file changed, 50 insertions(+), 61 deletions(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 2578d1837a..551482dab3 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -136,6 +136,15 @@ struct cmdline_info { /// Last value of prompt_id, incremented when doing new prompt static unsigned last_prompt_id = 0; +typedef struct { + colnr_T vs_curswant; + colnr_T vs_leftcol; + linenr_T vs_topline; + int vs_topfill; + linenr_T vs_botline; + int vs_empty_rows; +} viewstate_T; + typedef struct command_line_state { VimState state; int firstc; @@ -151,18 +160,8 @@ typedef struct command_line_state { int histype; // history type to be used pos_T search_start; // where 'incsearch' starts searching pos_T save_cursor; - colnr_T old_curswant; - colnr_T init_curswant; - colnr_T old_leftcol; - colnr_T init_leftcol; - linenr_T old_topline; - linenr_T init_topline; - int old_topfill; - int init_topfill; - linenr_T old_botline; - linenr_T init_botline; - int old_empty_rows; - int init_empty_rows; + viewstate_T init_viewstate; + viewstate_T old_viewstate; pos_T match_start; pos_T match_end; int did_incsearch; @@ -230,6 +229,28 @@ static int compl_selected; static int cmd_hkmap = 0; // Hebrew mapping during command line +static void save_viewstate(viewstate_T *vs) + FUNC_ATTR_NONNULL_ALL +{ + vs->vs_curswant = curwin->w_curswant; + vs->vs_leftcol = curwin->w_leftcol; + vs->vs_topline = curwin->w_topline; + vs->vs_topfill = curwin->w_topfill; + vs->vs_botline = curwin->w_botline; + vs->vs_empty_rows = curwin->w_empty_rows; +} + +static void restore_viewstate(viewstate_T *vs) + FUNC_ATTR_NONNULL_ALL +{ + curwin->w_curswant = vs->vs_curswant; + curwin->w_leftcol = vs->vs_leftcol; + curwin->w_topline = vs->vs_topline; + curwin->w_topfill = vs->vs_topfill; + curwin->w_botline = vs->vs_botline; + curwin->w_empty_rows = vs->vs_empty_rows; +} + /// Internal entry point for cmdline mode. /// /// caller must use save_cmdline and restore_cmdline. Best is to use @@ -240,22 +261,18 @@ static uint8_t *command_line_enter(int firstc, long count, int indent) static int cmdline_level = 0; cmdline_level++; - CommandLineState state, *s = &state; - memset(s, 0, sizeof(CommandLineState)); - s->firstc = firstc; - s->count = count; - s->indent = indent; - s->save_msg_scroll = msg_scroll; - s->save_State = State; + CommandLineState state = { + .firstc = firstc, + .count = count, + .indent = indent, + .save_msg_scroll = msg_scroll, + .save_State = State, + .ignore_drag_release = true, + .match_start = curwin->w_cursor, + }; + CommandLineState *s = &state; s->save_p_icm = vim_strsave(p_icm); - s->ignore_drag_release = true; - s->match_start = curwin->w_cursor; - s->init_curswant = curwin->w_curswant; - s->init_leftcol = curwin->w_leftcol; - s->init_topline = curwin->w_topline; - s->init_topfill = curwin->w_topfill; - s->init_botline = curwin->w_botline; - s->init_empty_rows = curwin->w_empty_rows; + save_viewstate(&state.init_viewstate); if (s->firstc == -1) { s->firstc = NUL; @@ -273,12 +290,7 @@ static uint8_t *command_line_enter(int firstc, long count, int indent) clearpos(&s->match_end); s->save_cursor = curwin->w_cursor; // may be restored later s->search_start = curwin->w_cursor; - s->old_curswant = curwin->w_curswant; - s->old_leftcol = curwin->w_leftcol; - s->old_topline = curwin->w_topline; - s->old_topfill = curwin->w_topfill; - s->old_botline = curwin->w_botline; - s->old_empty_rows = curwin->w_empty_rows; + save_viewstate(&state.old_viewstate); assert(indent >= 0); @@ -448,12 +460,7 @@ static uint8_t *command_line_enter(int firstc, long count, int indent) } curwin->w_cursor = s->search_start; // -V519 } - curwin->w_curswant = s->old_curswant; - curwin->w_leftcol = s->old_leftcol; - curwin->w_topline = s->old_topline; - curwin->w_topfill = s->old_topfill; - curwin->w_botline = s->old_botline; - curwin->w_empty_rows = s->old_empty_rows; + restore_viewstate(&s->old_viewstate); highlight_match = false; validate_cursor(); // needed for TAB redraw_all_later(SOME_VALID); @@ -1118,12 +1125,7 @@ static void command_line_next_incsearch(CommandLineState *s, bool next_match) update_topline(); validate_cursor(); highlight_match = true; - s->old_curswant = curwin->w_curswant; - s->old_leftcol = curwin->w_leftcol; - s->old_topline = curwin->w_topline; - s->old_topfill = curwin->w_topfill; - s->old_botline = curwin->w_botline; - s->old_empty_rows = curwin->w_empty_rows; + save_viewstate(&s->old_viewstate); update_screen(NOT_VALID); redrawcmdline(); } else { @@ -1244,12 +1246,7 @@ static int command_line_handle_key(CommandLineState *s) s->search_start = s->save_cursor; // save view settings, so that the screen won't be restored at the // wrong position - s->old_curswant = s->init_curswant; - s->old_leftcol = s->init_leftcol; - s->old_topline = s->init_topline; - s->old_topfill = s->init_topfill; - s->old_botline = s->init_botline; - s->old_empty_rows = s->init_empty_rows; + s->old_viewstate = s->init_viewstate; } redrawcmd(); } else if (ccline.cmdlen == 0 && s->c != Ctrl_W @@ -1879,11 +1876,7 @@ static int command_line_changed(CommandLineState *s) // first restore the old curwin values, so the screen is // positioned in the same way as the actual search command - curwin->w_leftcol = s->old_leftcol; - curwin->w_topline = s->old_topline; - curwin->w_topfill = s->old_topfill; - curwin->w_botline = s->old_botline; - curwin->w_empty_rows = s->old_empty_rows; + restore_viewstate(&s->old_viewstate); changed_cline_bef_curs(); update_topline(); @@ -1944,11 +1937,7 @@ static int command_line_changed(CommandLineState *s) // Restore the window "view". curwin->w_cursor = s->save_cursor; - curwin->w_curswant = s->old_curswant; - curwin->w_leftcol = s->old_leftcol; - curwin->w_topline = s->old_topline; - curwin->w_topfill = s->old_topfill; - curwin->w_botline = s->old_botline; + restore_viewstate(&s->old_viewstate); update_topline(); redrawcmdline(); -- cgit From 97dcc48c998ccecaa37a3cbea568d85c2f1407f9 Mon Sep 17 00:00:00 2001 From: akovaski Date: Tue, 21 Jan 2020 02:35:01 -0600 Subject: wildmode: fix wildmode=longest,full with pum #11690 With "wildmode=longest,full" + wildoptions=pum, wildmode should show popupmenu after Tab-Tab, not the horizontal wildmenu. Fixes #11622 --- src/nvim/ex_getln.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 551482dab3..e6b7bfaebf 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -941,8 +941,10 @@ static int command_line_execute(VimState *state, int key) // if 'wildmode' contains "list" may still need to list if (s->xpc.xp_numfiles > 1 && !s->did_wild_list - && (wim_flags[s->wim_index] & WIM_LIST)) { - (void)showmatches(&s->xpc, false); + && ((wim_flags[s->wim_index] & WIM_LIST) + || (p_wmnu && (wim_flags[s->wim_index] & WIM_FULL) != 0))) { + (void)showmatches(&s->xpc, p_wmnu + && ((wim_flags[s->wim_index] & WIM_LIST) == 0)); redrawcmd(); s->did_wild_list = true; } -- cgit From 961c528afc7f3a21a8c4b118a2c585dbe670c5c5 Mon Sep 17 00:00:00 2001 From: Billy Su Date: Wed, 22 Jan 2020 17:50:33 +0800 Subject: ex_getln.c: wildmenu add cancel and apply ops --- src/nvim/ex_getln.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 551482dab3..380dc43b50 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -621,6 +621,16 @@ static int command_line_execute(VimState *state, int key) s->c = Ctrl_N; } } + if (compl_match_array || s->did_wild_list) { + if (s->c == Ctrl_E) { + s->res = nextwild(&s->xpc, WILD_CANCEL, WILD_NO_BEEP, + s->firstc != '@'); + } else if (s->c == Ctrl_Y) { + s->res = nextwild(&s->xpc, WILD_APPLY, WILD_NO_BEEP, + s->firstc != '@'); + s->c = Ctrl_E; + } + } // Hitting CR after "emenu Name.": complete submenu if (s->xpc.xp_context == EXPAND_MENUNAMES && p_wmnu @@ -3788,6 +3798,12 @@ ExpandOne ( return NULL; } + if (mode == WILD_CANCEL) { + ss = vim_strsave(orig_save); + } else if (mode == WILD_APPLY) { + ss = vim_strsave(findex == -1 ? orig_save : xp->xp_files[findex]); + } + /* free old names */ if (xp->xp_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST) { FreeWild(xp->xp_numfiles, xp->xp_files); @@ -3799,7 +3815,7 @@ ExpandOne ( if (mode == WILD_FREE) /* only release file name */ return NULL; - if (xp->xp_numfiles == -1) { + if (xp->xp_numfiles == -1 && mode != WILD_APPLY && mode != WILD_CANCEL) { xfree(orig_save); orig_save = orig; orig_saved = TRUE; -- cgit From 14a8b3b98c245087ef431070195f3a2fa3db16c0 Mon Sep 17 00:00:00 2001 From: Hye Sung Jung Date: Fri, 31 Jan 2020 00:56:34 -0600 Subject: doc: fix typos [ci skip] #11787 --- src/nvim/ex_getln.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index e6b7bfaebf..f6833874ea 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -3040,7 +3040,7 @@ void cmdline_screen_cleared(void) } } -/// called by ui_flush, do what redraws neccessary to keep cmdline updated. +/// called by ui_flush, do what redraws necessary to keep cmdline updated. void cmdline_ui_flush(void) { if (!ui_has(kUICmdline)) { -- cgit From d50c1123d5616c9757bb5707416696cda1a43716 Mon Sep 17 00:00:00 2001 From: Jakub Łuczyński Date: Mon, 10 Feb 2020 18:34:18 +0100 Subject: fix: includes --- src/nvim/ex_getln.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index f6833874ea..b010dde1e3 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -23,6 +23,7 @@ #include "nvim/digraph.h" #include "nvim/edit.h" #include "nvim/eval.h" +#include "nvim/eval/user_funcs.h" #include "nvim/ex_cmds.h" #include "nvim/ex_cmds2.h" #include "nvim/ex_docmd.h" -- cgit From 5e815edece308a91296720cd6cb8d988af6c90c8 Mon Sep 17 00:00:00 2001 From: Jakub Łuczyński Date: Tue, 11 Feb 2020 16:19:14 +0100 Subject: rename: user_funcs -> userfunc Lets stick with vim for now --- src/nvim/ex_getln.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index b010dde1e3..e02443e061 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -23,7 +23,7 @@ #include "nvim/digraph.h" #include "nvim/edit.h" #include "nvim/eval.h" -#include "nvim/eval/user_funcs.h" +#include "nvim/eval/userfunc.h" #include "nvim/ex_cmds.h" #include "nvim/ex_cmds2.h" #include "nvim/ex_docmd.h" -- cgit From 986eafce4708c8f49552d7dcd0cc5fe471caa655 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 12 Feb 2020 21:33:51 -0500 Subject: vim-patch:8.1.2187: error for bad regexp even though regexp is not used Problem: Error for bad regexp even though regexp is not used when writing a file. (Arseny Nasokin) Solution: Ignore regexp errors. (closes vim/vim#5059) https://github.com/vim/vim/commit/b40c2576d4e0e2dd2c580414c45947d88556d76d --- src/nvim/ex_getln.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index f6833874ea..1c3c212aef 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -4693,6 +4693,9 @@ ExpandFromContext ( flags |= EW_KEEPALL; if (options & WILD_SILENT) flags |= EW_SILENT; + if (options & WILD_NOERROR) { + flags |= EW_NOERROR; + } if (options & WILD_ALLLINKS) { flags |= EW_ALLLINKS; } -- cgit From 93c6eb4a668b52394667feca86d5e57731828528 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 22 Feb 2020 12:59:39 -0800 Subject: PVS/V618: fix printf-style args #11888 We intentionally do not translate API errors. ref: https://github.com/neovim/neovim/issues/6150 --- src/nvim/ex_getln.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 1c3c212aef..c9f36ccd61 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2701,7 +2701,7 @@ static bool color_cmdline(CmdlineInfo *colored_ccline) goto color_cmdline_error; } if (tv.v_type != VAR_LIST) { - PRINT_ERRMSG(_("E5400: Callback should return list")); + PRINT_ERRMSG("%s", _("E5400: Callback should return list")); goto color_cmdline_error; } if (tv.vval.v_list == NULL) { -- cgit From 73dc9e943cfea92ec0254f6926c9524029cb0222 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 22 Mar 2020 09:51:46 -0400 Subject: vim-patch:8.1.2378: using old C style comments Problem: Using old C style comments. Solution: Use // comments where appropriate. https://github.com/vim/vim/commit/5d18efecfd6c45d69f55268948a22cd0465bb955 --- src/nvim/ex_getln.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 0c28f2ae70..ecaab76612 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2447,9 +2447,10 @@ redraw: /* make following messages go to the next line */ msg_didout = FALSE; msg_col = 0; - if (msg_row < Rows - 1) - ++msg_row; - emsg_on_display = FALSE; /* don't want os_delay() */ + if (msg_row < Rows - 1) { + msg_row++; + } + emsg_on_display = false; // don't want os_delay() if (got_int) ga_clear(&line_ga); -- cgit From 978a6bcaf2b98b3c89381a3eacf642b4f61db033 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Sun, 22 Mar 2020 21:40:12 +0000 Subject: vim-patch:8.1.2225: the "last used" info of a buffer is under used Problem: The "last used" info of a buffer is under used. Solution: Add "lastused" to getbufinfo(). List buffers sorted by last-used field. (Andi Massimino, closes vim/vim#4722) https://github.com/vim/vim/commit/52410575be50d5c40bbe6380159df48cfc382ceb --- src/nvim/ex_getln.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index ecaab76612..d9a63ff6da 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -947,6 +947,10 @@ static int command_line_execute(VimState *state, int key) // - wildcard expansion is only done when the 'wildchar' key is really // typed, not when it comes from a macro if ((s->c == p_wc && !s->gotesc && KeyTyped) || s->c == p_wcm) { + int options = WILD_NO_BEEP; + if (wim_flags[s->wim_index] & WIM_BUFLASTUSED) { + options |= WILD_BUFLASTUSED; + } if (s->xpc.xp_numfiles > 0) { // typed p_wc at least twice // if 'wildmode' contains "list" may still need to list if (s->xpc.xp_numfiles > 1 @@ -960,11 +964,11 @@ static int command_line_execute(VimState *state, int key) } if (wim_flags[s->wim_index] & WIM_LONGEST) { - s->res = nextwild(&s->xpc, WILD_LONGEST, WILD_NO_BEEP, - s->firstc != '@'); + s->res = nextwild(&s->xpc, WILD_LONGEST, options, + s->firstc != '@'); } else if (wim_flags[s->wim_index] & WIM_FULL) { - s->res = nextwild(&s->xpc, WILD_NEXT, WILD_NO_BEEP, - s->firstc != '@'); + s->res = nextwild(&s->xpc, WILD_NEXT, options, + s->firstc != '@'); } else { s->res = OK; // don't insert 'wildchar' now } @@ -975,11 +979,11 @@ static int command_line_execute(VimState *state, int key) // if 'wildmode' first contains "longest", get longest // common part if (wim_flags[0] & WIM_LONGEST) { - s->res = nextwild(&s->xpc, WILD_LONGEST, WILD_NO_BEEP, - s->firstc != '@'); + s->res = nextwild(&s->xpc, WILD_LONGEST, options, + s->firstc != '@'); } else { - s->res = nextwild(&s->xpc, WILD_EXPAND_KEEP, WILD_NO_BEEP, - s->firstc != '@'); + s->res = nextwild(&s->xpc, WILD_EXPAND_KEEP, options, + s->firstc != '@'); } // if interrupted while completing, behave like it failed @@ -1016,11 +1020,11 @@ static int command_line_execute(VimState *state, int key) s->did_wild_list = true; if (wim_flags[s->wim_index] & WIM_LONGEST) { - nextwild(&s->xpc, WILD_LONGEST, WILD_NO_BEEP, - s->firstc != '@'); + nextwild(&s->xpc, WILD_LONGEST, options, + s->firstc != '@'); } else if (wim_flags[s->wim_index] & WIM_FULL) { - nextwild(&s->xpc, WILD_NEXT, WILD_NO_BEEP, - s->firstc != '@'); + nextwild(&s->xpc, WILD_NEXT, options, + s->firstc != '@'); } } else { vim_beep(BO_WILD); -- cgit From f5c1314cb01164879fb9df6bce01151371c16f7d Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 31 May 2020 12:06:47 -0400 Subject: vim-patch:8.2.0089: crash when running out of memory in :setfiletype completion Problem: Crash when running out of memory in :setfiletype completion. Solution: Do not allocate memory. (Dominique Pelle, closes vim/vim#5438) https://github.com/vim/vim/commit/f0f8055102c264b1d0c0a79bf742dc126fb447b9 --- src/nvim/ex_getln.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index b799e86ff7..56a8f56753 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -5361,12 +5361,12 @@ void globpath(char_u *path, char_u *file, garray_T *ga, int expand_options) // Concatenate new results to previous ones. ga_grow(ga, num_p); + // take over the pointers and put them in "ga" for (int i = 0; i < num_p; i++) { - ((char_u **)ga->ga_data)[ga->ga_len] = vim_strsave(p[i]); + ((char_u **)ga->ga_data)[ga->ga_len] = p[i]; ga->ga_len++; } - - FreeWild(num_p, p); + xfree(p); } } } -- cgit From 1805fb469a39d998f9bef0415999aa835d051044 Mon Sep 17 00:00:00 2001 From: Billy Su Date: Tue, 28 Apr 2020 23:21:50 +0800 Subject: vim-patch:8.2.0111: VAR_SPECIAL is also used for booleans Problem: VAR_SPECIAL is also used for booleans. Solution: Add VAR_BOOL for better type checking. https://github.com/vim/vim/commit/9b4a15d5dba354d2e1e02871470bad103f34769a --- src/nvim/ex_getln.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 56a8f56753..1a836b7a98 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -432,8 +432,8 @@ static uint8_t *command_line_enter(int firstc, long count, int indent) tv_dict_add_nr(dict, S_LEN("cmdlevel"), ccline.level); tv_dict_set_keys_readonly(dict); // not readonly: - tv_dict_add_special(dict, S_LEN("abort"), - s->gotesc ? kSpecialVarTrue : kSpecialVarFalse); + tv_dict_add_bool(dict, S_LEN("abort"), + s->gotesc ? kBoolVarTrue : kBoolVarFalse); try_enter(&tstate); apply_autocmds(EVENT_CMDLINELEAVE, (char_u *)firstcbuf, (char_u *)firstcbuf, false, curbuf); -- cgit From a02a267f8ad4b6d8b9038d2c7d9b85f03e734814 Mon Sep 17 00:00:00 2001 From: Ville Hakulinen Date: Wed, 15 Jul 2020 15:46:47 +0300 Subject: Reuse inccommand preview window (fix #11529) (#12612) * Reuse inccommand preview window Currently, show_sub (inside ex_substitute) creates a new split on each run for its existing buffer, and ex_substitute calls close_windows for it. This functionality seems to relay in delayed operations on window structures where the close event on the newest window is "cancelled" by win_grid_alloc. But for multigrid, there is optimization in place in win_grid_alloc which causes any (unnecessary?) allocations to be skipped, and thus inccommand preview window is not preserved but closed immediately. Alternative fix would be to remove said optimization, but the whole "lets create a new split each time and trash the earlier window" seems too wasteful. Fix #11529 * Update failing test The failing test sets inccommand=split and does `:%s/.`, but isn't expecting to get any contents for the preview window, other than the windows status line. Update the test to include the preview window contents too. --- src/nvim/ex_getln.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/nvim/ex_getln.c') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 1a836b7a98..93684e8606 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -450,6 +450,11 @@ static uint8_t *command_line_enter(int firstc, long count, int indent) ExpandCleanup(&s->xpc); ccline.xpc = NULL; + if (s->gotesc) { + // There might be a preview window open for inccommand. Close it. + close_preview_windows(); + } + if (s->did_incsearch) { if (s->gotesc) { curwin->w_cursor = s->save_cursor; @@ -1958,8 +1963,10 @@ static int command_line_changed(CommandLineState *s) update_topline(); redrawcmdline(); + } else if (State & CMDPREVIEW) { State = (State & ~CMDPREVIEW); + close_preview_windows(); update_screen(SOME_VALID); // Clear 'inccommand' preview. } -- cgit