diff options
author | bfredl <bjorn.linse@gmail.com> | 2023-03-09 11:45:20 +0100 |
---|---|---|
committer | bfredl <bjorn.linse@gmail.com> | 2023-03-12 10:18:57 +0100 |
commit | 846a056744bf458d4376cd7638c94f7c82862046 (patch) | |
tree | 96121391a4fec3845248eab7571819c9ebbda1a6 | |
parent | d15abd1be4ae85b10174e3ee139d3b7605e87577 (diff) | |
download | rneovim-846a056744bf458d4376cd7638c94f7c82862046.tar.gz rneovim-846a056744bf458d4376cd7638c94f7c82862046.tar.bz2 rneovim-846a056744bf458d4376cd7638c94f7c82862046.zip |
refactor(redraw): make cursor position redraw use the "redraw later" pattern
-rw-r--r-- | src/nvim/drawscreen.c | 32 | ||||
-rw-r--r-- | src/nvim/edit.c | 9 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 2 | ||||
-rw-r--r-- | src/nvim/normal.c | 17 | ||||
-rw-r--r-- | src/nvim/option.c | 3 | ||||
-rw-r--r-- | src/nvim/optionstr.c | 1 | ||||
-rw-r--r-- | src/nvim/search.c | 4 | ||||
-rw-r--r-- | test/functional/ex_cmds/map_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/ui/messages_spec.lua | 3 |
9 files changed, 31 insertions, 42 deletions
diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c index 384dbf82f9..d8c9da870a 100644 --- a/src/nvim/drawscreen.c +++ b/src/nvim/drawscreen.c @@ -728,19 +728,15 @@ static void win_redr_border(win_T *wp) /// Show current cursor info in ruler and various other places /// /// @param always if false, only show ruler if position has changed. -void show_cursor_info(bool always) +void show_cursor_info_later(bool force) { - if (!always && !redrawing()) { - return; - } - int state = get_real_state(); int empty_line = (State & MODE_INSERT) == 0 && *ml_get_buf(curwin->w_buffer, curwin->w_cursor.lnum, false) == NUL; // Only draw when something changed. validate_virtcol_win(curwin); - if (always + if (force || curwin->w_cursor.lnum != curwin->w_stl_cursor.lnum || curwin->w_cursor.col != curwin->w_stl_cursor.col || curwin->w_virtcol != curwin->w_stl_virtcol @@ -750,27 +746,19 @@ void show_cursor_info(bool always) || curwin->w_topfill != curwin->w_stl_topfill || empty_line != curwin->w_stl_empty || state != curwin->w_stl_state) { - win_check_ns_hl(curwin); - if ((*p_stl != NUL || *curwin->w_p_stl != NUL) - && (curwin->w_status_height || global_stl_height())) { - redraw_custom_statusline(curwin); + if ((curwin->w_status_height || global_stl_height())) { + curwin->w_redr_status = true; } else { - win_redr_ruler(curwin); + redraw_cmdline = true; } + if (*p_wbr != NUL || *curwin->w_p_wbr != NUL) { - win_redr_winbar(curwin); + curwin->w_redr_status = true; } - if (need_maketitle - || (p_icon && (stl_syntax & STL_IN_ICON)) + if ((p_icon && (stl_syntax & STL_IN_ICON)) || (p_title && (stl_syntax & STL_IN_TITLE))) { - maketitle(); - } - - win_check_ns_hl(NULL); - // Redraw the tab pages line if needed. - if (redraw_tabline) { - draw_tabline(); + need_maketitle = true; } } @@ -2136,7 +2124,7 @@ void status_redraw_all(void) bool is_stl_global = global_stl_height() != 0; FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { - if ((!is_stl_global && wp->w_status_height) || (is_stl_global && wp == curwin) + if ((!is_stl_global && wp->w_status_height) || wp == curwin || wp->w_winbar_height) { wp->w_redr_status = true; redraw_later(wp, UPD_VALID); diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 6e8dc8fc02..48ba93e666 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -1350,12 +1350,15 @@ void ins_redraw(bool ready) } pum_check_clear(); + show_cursor_info_later(false); if (must_redraw) { update_screen(); - } else if (clear_cmdline || redraw_cmdline) { - showmode(); // clear cmdline and show mode + } else { + redraw_statuslines(); + if (clear_cmdline || redraw_cmdline || redraw_mode) { + showmode(); // clear cmdline and show mode + } } - show_cursor_info(false); setcursor(); emsg_on_display = false; // may remove error message now } diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index a12c2a15b4..d398d3e06e 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -3747,6 +3747,7 @@ static int do_sub(exarg_T *eap, proftime_T timeout, long cmdpreview_ns, handle_T update_topline(curwin); validate_cursor(); redraw_later(curwin, UPD_SOME_VALID); + show_cursor_info_later(true); update_screen(); highlight_match = false; redraw_later(curwin, UPD_SOME_VALID); @@ -3765,7 +3766,6 @@ static int do_sub(exarg_T *eap, proftime_T timeout, long cmdpreview_ns, handle_T _("replace with %s (y/n/a/q/l/^E/^Y)?"), sub); msg_no_more = false; msg_scroll = (int)i; - show_cursor_info(true); if (!ui_has(kUIMessages)) { ui_cursor_goto(msg_row, msg_col); } diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 890215e754..2a8fbbb962 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1306,16 +1306,20 @@ static void normal_redraw(NormalState *s) update_topline(curwin); validate_cursor(); + show_cursor_info_later(false); + if (VIsual_active) { redraw_curbuf_later(UPD_INVERTED); // update inverted part - update_screen(); - } else if (must_redraw) { - update_screen(); - } else if (redraw_cmdline || clear_cmdline || redraw_mode) { - showmode(); } - redraw_statuslines(); + if (must_redraw) { + update_screen(); + } else { + redraw_statuslines(); + if (redraw_cmdline || clear_cmdline || redraw_mode) { + showmode(); + } + } if (need_maketitle) { maketitle(); @@ -1348,7 +1352,6 @@ static void normal_redraw(NormalState *s) did_emsg = false; msg_didany = false; // reset lines_left in msg_start() may_clear_sb_text(); // clear scroll-back text on next msg - show_cursor_info(false); setcursor(); } diff --git a/src/nvim/option.c b/src/nvim/option.c index 4e0fbc20f8..e4baddbeef 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2255,9 +2255,6 @@ static char *set_bool_option(const int opt_idx, char *const varp, const int valu if ((int *)varp == &p_ru || (int *)varp == &p_sc) { // in case 'ruler' or 'showcmd' changed comp_col(); - if ((int *)varp == &p_ru) { - win_redr_ruler(curwin); - } } if (curwin->w_curswant != MAXCOL && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) { diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index 0774baf2d8..5127bb2097 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -1221,7 +1221,6 @@ static void did_set_statusline(win_T *win, char **varp, char **gvarp, char **err } if (varp == &p_ruf && *errmsg == NULL) { comp_col(); - win_redr_ruler(curwin); } // add / remove window bars for 'winbar' if (gvarp == &p_wbr) { diff --git a/src/nvim/search.c b/src/nvim/search.c index e5a456161f..782f60f11f 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -2340,7 +2340,6 @@ void showmatch(int c) dollar_vcol = -1; } curwin->w_virtcol++; // do display ')' just before "$" - update_screen(); // show the new char first colnr_T save_dollar_vcol = dollar_vcol; int save_state = State; @@ -2349,7 +2348,8 @@ void showmatch(int c) curwin->w_cursor = mpos; // move to matching char *so = 0; // don't use 'scrolloff' here *siso = 0; // don't use 'sidescrolloff' here - show_cursor_info(false); + show_cursor_info_later(false); + update_screen(); // show the new char setcursor(); ui_flush(); // Restore dollar_vcol(), because setcursor() may call curs_rows() diff --git a/test/functional/ex_cmds/map_spec.lua b/test/functional/ex_cmds/map_spec.lua index ec912053b2..a197b81cc5 100644 --- a/test/functional/ex_cmds/map_spec.lua +++ b/test/functional/ex_cmds/map_spec.lua @@ -152,7 +152,7 @@ describe('Screen', function() ~ | ~ | ~ | - > | + -- INSERT -- | ]]) end) diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 212d3aee7d..db45e80dae 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -474,8 +474,7 @@ describe('ui/ext_messages', function() ]], msg_history={{ content = {{ "stuff" }}, kind = "echomsg", - }}, showmode={{ "-- INSERT --", 3 }}, - messages={{ + }}, messages={{ content = {{ "Press ENTER or type command to continue", 4}}, kind = "return_prompt" }}} |