diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2024-05-24 19:18:11 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2024-05-24 19:18:11 +0000 |
commit | ff7ed8f586589d620a806c3758fac4a47a8e7e15 (patch) | |
tree | 729bbcb92231538fa61dab6c3d890b025484b7f5 /src/nvim/ex_getln.c | |
parent | 376914f419eb08fdf4c1a63a77e1f035898a0f10 (diff) | |
parent | 28c04948a1c887a1cc0cb64de79fa32631700466 (diff) | |
download | rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.tar.gz rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.tar.bz2 rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.zip |
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'src/nvim/ex_getln.c')
-rw-r--r-- | src/nvim/ex_getln.c | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 44a78711d2..f18dc0f747 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -470,7 +470,7 @@ static void may_do_incsearch_highlighting(int firstc, int count, incsearch_state .sa_tm = &tm, }; found = do_search(NULL, firstc == ':' ? '/' : firstc, search_delim, - ccline.cmdbuff + skiplen, count, + ccline.cmdbuff + skiplen, (size_t)patlen, count, search_flags, &sia); ccline.cmdbuff[skiplen + patlen] = next_char; emsg_off--; @@ -510,7 +510,7 @@ static void may_do_incsearch_highlighting(int firstc, int count, incsearch_state s->match_start = curwin->w_cursor; set_search_match(&curwin->w_cursor); - validate_cursor(); + validate_cursor(curwin); end_pos = curwin->w_cursor; s->match_end = end_pos; curwin->w_cursor = save_pos; @@ -530,7 +530,7 @@ static void may_do_incsearch_highlighting(int firstc, int count, incsearch_state ccline.cmdbuff[skiplen + patlen] = next_char; } - validate_cursor(); + validate_cursor(curwin); // May redraw the status line to show the cursor position. if (p_ru && (curwin->w_status_height > 0 || global_stl_height() > 0)) { @@ -626,7 +626,7 @@ static void finish_incsearch_highlighting(bool gotesc, incsearch_state_T *s, magic_overruled = s->magic_overruled_save; - validate_cursor(); // needed for TAB + validate_cursor(curwin); // needed for TAB status_redraw_all(); redraw_all_later(UPD_SOME_VALID); if (call_update_screen) { @@ -767,7 +767,7 @@ static uint8_t *command_line_enter(int firstc, int count, int indent, bool clear } setmouse(); - ui_cursor_shape(); // may show different cursor shape + setcursor(); TryState tstate; Error err = ERROR_INIT; @@ -884,11 +884,12 @@ static uint8_t *command_line_enter(int firstc, int count, int indent, bool clear && ccline.cmdlen && s->firstc != NUL && (s->some_key_typed || s->histype == HIST_SEARCH)) { - add_to_history(s->histype, ccline.cmdbuff, true, + size_t cmdbufflen = strlen(ccline.cmdbuff); + add_to_history(s->histype, ccline.cmdbuff, cmdbufflen, true, s->histype == HIST_SEARCH ? s->firstc : NUL); if (s->firstc == ':') { xfree(new_last_cmdline); - new_last_cmdline = xstrdup(ccline.cmdbuff); + new_last_cmdline = xstrnsave(ccline.cmdbuff, cmdbufflen); } } @@ -919,7 +920,7 @@ static uint8_t *command_line_enter(int firstc, int count, int indent, bool clear need_wait_return = false; } - set_string_option_direct(kOptInccommand, s->save_p_icm, 0, SID_NONE); + set_option_direct(kOptInccommand, CSTR_AS_OPTVAL(s->save_p_icm), 0, SID_NONE); State = s->save_State; if (cmdpreview != save_cmdpreview) { cmdpreview = save_cmdpreview; // restore preview state @@ -927,7 +928,6 @@ static uint8_t *command_line_enter(int firstc, int count, int indent, bool clear } may_trigger_modechanged(); setmouse(); - ui_cursor_shape(); // may show different cursor shape sb_text_end_cmdline(); theend: @@ -1168,6 +1168,7 @@ static int command_line_execute(VimState *state, int key) return -1; // get another key } + disptick_T display_tick_saved = display_tick; CommandLineState *s = (CommandLineState *)state; s->c = key; @@ -1179,6 +1180,10 @@ static int command_line_execute(VimState *state, int key) } else { map_execute_lua(false); } + // Re-apply 'incsearch' highlighting in case it was cleared. + if (display_tick > display_tick_saved && s->is_state.did_incsearch) { + may_do_incsearch_highlighting(s->firstc, s->count, &s->is_state); + } // nvim_select_popupmenu_item() can be called from the handling of // K_EVENT, K_COMMAND, or K_LUA. @@ -1447,7 +1452,7 @@ static int may_do_command_line_next_incsearch(int firstc, int count, incsearch_s pat[patlen] = NUL; int found = searchit(curwin, curbuf, &t, NULL, next_match ? FORWARD : BACKWARD, - pat, count, search_flags, + pat, (size_t)patlen, count, search_flags, RE_SEARCH, NULL); emsg_off--; pat[patlen] = save; @@ -1483,7 +1488,7 @@ static int may_do_command_line_next_incsearch(int firstc, int count, incsearch_s curwin->w_cursor = s->match_start; changed_cline_bef_curs(curwin); update_topline(curwin); - validate_cursor(); + validate_cursor(curwin); highlight_match = true; save_viewstate(curwin, &s->old_viewstate); redraw_later(curwin, UPD_NOT_VALID); @@ -1964,7 +1969,7 @@ static int command_line_handle_key(CommandLineState *s) return command_line_not_changed(s); // Ignore mouse case K_MIDDLEMOUSE: - cmdline_paste(eval_has_provider("clipboard") ? '*' : 0, true, true); + cmdline_paste(eval_has_provider("clipboard", false) ? '*' : 0, true, true); redrawcmd(); return command_line_changed(s); @@ -2550,7 +2555,7 @@ static bool cmdpreview_may_show(CommandLineState *s) // Open preview buffer if inccommand=split. if (icm_split && (cmdpreview_buf = cmdpreview_open_buf()) == NULL) { // Failed to create preview buffer, so disable preview. - set_string_option_direct(kOptInccommand, "nosplit", 0, SID_NONE); + set_option_direct(kOptInccommand, STATIC_CSTR_AS_OPTVAL("nosplit"), 0, SID_NONE); icm_split = false; } // Setup preview namespace if it's not already set. @@ -3445,9 +3450,11 @@ void cmdline_screen_cleared(void) /// called by ui_flush, do what redraws necessary to keep cmdline updated. void cmdline_ui_flush(void) { - if (!ui_has(kUICmdline)) { + static bool flushing = false; + if (!ui_has(kUICmdline) || flushing) { return; } + flushing = true; int level = ccline.level; CmdlineInfo *line = &ccline; while (level > 0 && line) { @@ -3462,6 +3469,7 @@ void cmdline_ui_flush(void) } line = line->prev_ccline; } + flushing = false; } // Put a character on the command line. Shifts the following text to the @@ -3859,7 +3867,6 @@ void cursorcmd(void) if (ccline.redraw_state < kCmdRedrawPos) { ccline.redraw_state = kCmdRedrawPos; } - setcursor(); return; } @@ -4553,6 +4560,7 @@ static int open_cmdwin(void) State = save_State; may_trigger_modechanged(); setmouse(); + setcursor(); return cmdwin_result; } @@ -4583,7 +4591,7 @@ char *script_get(exarg_T *const eap, size_t *const lenp) { char *cmd = eap->arg; - if (cmd[0] != '<' || cmd[1] != '<' || eap->getline == NULL) { + if (cmd[0] != '<' || cmd[1] != '<' || eap->ea_getline == NULL) { *lenp = strlen(eap->arg); return eap->skip ? NULL : xmemdupz(eap->arg, *lenp); } @@ -4623,6 +4631,6 @@ static void set_search_match(pos_T *t) t->col = search_match_endcol; if (t->lnum > curbuf->b_ml.ml_line_count) { t->lnum = curbuf->b_ml.ml_line_count; - coladvance(MAXCOL); + coladvance(curwin, MAXCOL); } } |