diff options
Diffstat (limited to 'src/nvim/ex_getln.c')
-rw-r--r-- | src/nvim/ex_getln.c | 96 |
1 files changed, 51 insertions, 45 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 3f7bc45c2e..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; @@ -1075,7 +1077,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 +1820,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 +1847,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) { @@ -1924,7 +1929,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". @@ -1991,7 +1998,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 +2175,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 +2196,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; @@ -2320,7 +2330,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; @@ -5000,19 +5010,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); @@ -6065,12 +6080,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 <C-R>=<C-F> one can open the // command line window, but we don't want the popup menu then. pum_undisplay(true); @@ -6079,10 +6091,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(); @@ -6097,13 +6108,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) { @@ -6115,11 +6124,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]; @@ -6160,9 +6169,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; @@ -6179,10 +6189,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. @@ -6241,9 +6251,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); @@ -6256,10 +6264,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); @@ -6308,7 +6314,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); |