diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c index 097733275f..237247400e 100644 --- a/src/nvim/drawscreen.c +++ b/src/nvim/drawscreen.c @@ -597,6 +597,11 @@ int update_screen(void) curwin->w_redr_type = UPD_NOT_VALID; } + if (curwin->w_redr_type == UPD_INVERTED) { + // Update w_curswant so that the end of Visual selection is correct. + update_curswant(); + } + // Redraw the tab pages line if needed. if (redraw_tabline || type >= UPD_NOT_VALID) { update_window_hl(curwin, type >= UPD_NOT_VALID); diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 0cd2204c06..22cd601f2f 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -423,6 +423,26 @@ describe('highlight', function() ]]) end) + it('blockwise Visual highlight with virtualedit=block #34235', function() + local screen = Screen.new(45, 5) + command('set virtualedit=block') + insert('foobar\nfoo') + feed('0k$') + screen:expect([[ + {17:foobar}^ | + {17:foo } | + {1:~ }|*2 + {5:-- VISUAL BLOCK --} | + ]]) + feed('10l') + screen:expect([[ + {17:foobar }^ | + {17:foo } | + {1:~ }|*2 + {5:-- VISUAL BLOCK --} | + ]]) + end) + it('cterm=standout gui=standout', function() local screen = Screen.new(20, 5) screen:add_extra_attr_ids {