diff options
Diffstat (limited to 'src/nvim/screen.c')
-rw-r--r-- | src/nvim/screen.c | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 2eeeebb88d..dc028f0ed7 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -620,7 +620,7 @@ int update_screen(int type) /* Clear or redraw the command line. Done last, because scrolling may * mess up the command line. */ - if (clear_cmdline || redraw_cmdline) { + if (clear_cmdline || redraw_cmdline || redraw_mode) { showmode(); } @@ -683,7 +683,7 @@ void conceal_check_cursor_line(void) redrawWinline(curwin, curwin->w_cursor.lnum); // Need to recompute cursor column, e.g., when starting Visual mode // without concealing. */ - curs_columns(true); + curs_columns(curwin, true); } } @@ -1698,7 +1698,7 @@ static void win_update(win_T *wp, Providers *providers) const int new_wcol = wp->w_wcol; recursive = true; curwin->w_valid &= ~VALID_TOPLINE; - update_topline(); // may invalidate w_botline again + update_topline(curwin); // may invalidate w_botline again if (old_wcol != new_wcol && (wp->w_valid & (VALID_WCOL|VALID_WROW)) @@ -2013,6 +2013,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, // end-of-line int lcs_eol_one = wp->w_p_lcs_chars.eol; // 'eol' until it's been used int lcs_prec_todo = wp->w_p_lcs_chars.prec; // 'prec' until it's been used + bool has_fold = foldinfo.fi_level != 0 && foldinfo.fi_lines >= 0; // saved "extra" items for when draw_state becomes WL_LINE (again) int saved_n_extra = 0; @@ -2196,7 +2197,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, } if (wp->w_p_spell - && foldinfo.fi_lines == 0 + && !has_fold && *wp->w_s->b_p_spl != NUL && !GA_EMPTY(&wp->w_s->b_langp) && *(char **)(wp->w_s->b_langp.ga_data) != NULL) { @@ -2299,6 +2300,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, // handle 'incsearch' and ":s///c" highlighting } else if (highlight_match && wp == curwin + && !has_fold && lnum >= curwin->w_cursor.lnum && lnum <= curwin->w_cursor.lnum + search_match_lines) { if (lnum == curwin->w_cursor.lnum) { @@ -2551,7 +2553,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, cur = wp->w_match_head; shl_flag = false; while ((cur != NULL || !shl_flag) && !number_only - && foldinfo.fi_lines == 0 + && !has_fold ) { if (!shl_flag) { shl = &search_hl; @@ -3883,8 +3885,8 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, /* check if line ends before left margin */ if (vcol < v + col - win_col_off(wp)) vcol = v + col - win_col_off(wp); - /* Get rid of the boguscols now, we want to draw until the right - * edge for 'cursorcolumn'. */ + // Get rid of the boguscols now, we want to draw until the right + // edge for 'cursorcolumn'. col -= boguscols; // boguscols = 0; // Disabled because value never read after this @@ -6557,12 +6559,28 @@ void grid_del_lines(ScreenGrid *grid, int row, int line_count, int end, int col, return; } +// Return true when postponing displaying the mode message: when not redrawing +// or inside a mapping. +bool skip_showmode(void) +{ + // Call char_avail() only when we are going to show something, because it + // takes a bit of time. redrawing() may also call char_avail_avail(). + if (global_busy + || msg_silent != 0 + || !redrawing() + || (char_avail() && !KeyTyped)) { + redraw_mode = true; // show mode later + return true; + } + return false; +} // Show the current mode and ruler. // // If clear_cmdline is TRUE, clear the rest of the cmdline. // If clear_cmdline is FALSE there may be a message there that needs to be // cleared only if a mode is shown. +// If redraw_mode is true show or clear the mode. // Return the length of the message (0 if no message). int showmode(void) { @@ -6588,12 +6606,8 @@ int showmode(void) || restart_edit || VIsual_active)); if (do_mode || reg_recording != 0) { - // Don't show mode right now, when not redrawing or inside a mapping. - // Call char_avail() only when we are going to show something, because - // it takes a bit of time. - if (!redrawing() || (char_avail() && !KeyTyped) || msg_silent != 0) { - redraw_cmdline = TRUE; /* show mode later */ - return 0; + if (skip_showmode()) { + return 0; // show mode later } nwr_save = need_wait_return; @@ -6713,10 +6727,11 @@ int showmode(void) need_clear = true; } - mode_displayed = TRUE; - if (need_clear || clear_cmdline) + mode_displayed = true; + if (need_clear || clear_cmdline || redraw_mode) { msg_clr_eos(); - msg_didout = FALSE; /* overwrite this message */ + } + msg_didout = false; // overwrite this message length = msg_col; msg_col = 0; msg_no_more = false; @@ -6725,6 +6740,9 @@ int showmode(void) } else if (clear_cmdline && msg_silent == 0) { // Clear the whole command line. Will reset "clear_cmdline". msg_clr_cmdline(); + } else if (redraw_mode) { + msg_pos_mode(); + msg_clr_eos(); } // NB: also handles clearing the showmode if it was emtpy or disabled @@ -6741,6 +6759,7 @@ int showmode(void) win_redr_ruler(last, true); } redraw_cmdline = false; + redraw_mode = false; clear_cmdline = false; return length; @@ -7380,7 +7399,7 @@ void screen_resize(int width, int height) cmdline_pum_display(false); } } else { - update_topline(); + update_topline(curwin); if (pum_drawn()) { // TODO(bfredl): ins_compl_show_pum wants to redraw the screen first. // For now make sure the nested update_screen(0) won't redraw the |