fix(statusline): redraw when VIsual_mode changes

(cherry picked from commit 397d861566)
This commit is contained in:
zeertzjq 2023-06-06 18:03:01 +08:00 committed by github-actions[bot]
parent 55373061ab
commit 7e7fc4885f
3 changed files with 61 additions and 4 deletions

View File

@ -1287,8 +1287,9 @@ struct window_S {
linenr_T w_stl_line_count; // line count when last redrawn
int w_stl_topfill; // topfill when last redrawn
char w_stl_empty; // true if elements show 0-1 (empty line)
int w_stl_state; // State when last redrawn
int w_stl_recording; // reg_recording when last redrawn
int w_stl_state; // get_real_state() when last redrawn
int w_stl_visual_mode; // VIsual_mode when last redrawn
int w_alt_fnum; // alternate file (for # and CTRL-^)

View File

@ -838,7 +838,8 @@ void show_cursor_info_later(bool force)
|| curwin->w_topfill != curwin->w_stl_topfill
|| empty_line != curwin->w_stl_empty
|| reg_recording != curwin->w_stl_recording
|| state != curwin->w_stl_state) {
|| state != curwin->w_stl_state
|| (VIsual_active && VIsual_mode != curwin->w_stl_visual_mode)) {
if (curwin->w_status_height || global_stl_height()) {
curwin->w_redr_status = true;
} else {
@ -861,8 +862,11 @@ void show_cursor_info_later(bool force)
curwin->w_stl_topline = curwin->w_topline;
curwin->w_stl_line_count = curwin->w_buffer->b_ml.ml_line_count;
curwin->w_stl_topfill = curwin->w_topfill;
curwin->w_stl_state = state;
curwin->w_stl_recording = reg_recording;
curwin->w_stl_state = state;
if (VIsual_active) {
curwin->w_stl_visual_mode = VIsual_mode;
}
}
/// @return true when postponing displaying the mode message: when not redrawing

View File

@ -627,11 +627,19 @@ it('K_EVENT does not trigger a statusline redraw unnecessarily', function()
eq(1, eval('g:counter < 50'), 'g:counter=' .. eval('g:counter'))
end)
it('statusline is redrawn on recording state change #22683', function()
it('statusline is redrawn on various state changes', function()
clear()
local screen = Screen.new(40, 4)
screen:attach()
-- recording state change #22683
command('set ls=2 stl=%{repeat(reg_recording(),5)}')
screen:expect([[
^ |
~ |
|
|
]])
feed('qQ')
screen:expect([[
^ |
@ -639,6 +647,50 @@ it('statusline is redrawn on recording state change #22683', function()
QQQQQ |
recording @Q |
]])
feed('q')
screen:expect([[
^ |
~ |
|
|
]])
-- Visual mode change #23932
command('set ls=2 stl=%{mode(1)}')
screen:expect([[
^ |
~ |
n |
|
]])
feed('v')
screen:expect([[
^ |
~ |
v |
-- VISUAL -- |
]])
feed('V')
screen:expect([[
^ |
~ |
V |
-- VISUAL LINE -- |
]])
feed('<C-V>')
screen:expect([[
^ |
~ |
^V |
-- VISUAL BLOCK -- |
]])
feed('<Esc>')
screen:expect([[
^ |
~ |
n |
|
]])
end)
it('ruler is redrawn in cmdline with redrawstatus #22804', function()