fix(mouse): click after eol with conceal and virtual text (#27897)

Problem:  Wrong cursor position when clicking after end of line with
          'virtualedit', conceal and virtual text.
Solution: Always fill linebuf_vcol[] for the columns to clear.
This commit is contained in:
zeertzjq
2024-03-17 17:54:18 +08:00
committed by GitHub
parent 54db75e995
commit 091eb4c8c7
2 changed files with 66 additions and 4 deletions

View File

@@ -34,6 +34,7 @@ describe('ui/mouse/input', function()
[6] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
[7] = { bold = true, foreground = Screen.colors.SeaGreen4 },
[8] = { foreground = Screen.colors.Brown },
[9] = { background = Screen.colors.DarkGrey, foreground = Screen.colors.LightGrey },
})
command('set mousemodel=extend')
feed('itesting<cr>mouse<cr>support and selection<esc>')
@@ -1638,6 +1639,59 @@ describe('ui/mouse/input', function()
end)
end)
it('virtual text does not change cursor placement on concealed line', function()
command('%delete')
insert('aaaaaaaaaa|hidden|bbbbbbbbbb|hidden|cccccccccc')
command('syntax match test /|hidden|/ conceal cchar=X')
command('set conceallevel=2 concealcursor=n virtualedit=all')
screen:expect([[
aaaaaaaaaa{9:X}bbbbbbb |
bbb{9:X}ccccccccc^c |
{0:~ }|*2
|
]])
api.nvim_input_mouse('left', 'press', '', 0, 0, 22)
screen:expect([[
aaaaaaaaaa{9:X}bbbbbb^b |
bbb{9:X}cccccccccc |
{0:~ }|*2
|
]])
api.nvim_input_mouse('left', 'press', '', 0, 1, 16)
screen:expect([[
aaaaaaaaaa{9:X}bbbbbbb |
bbb{9:X}cccccccccc ^ |
{0:~ }|*2
|
]])
api.nvim_buf_set_extmark(0, api.nvim_create_namespace(''), 0, 0, {
virt_text = { { '?', 'ErrorMsg' } },
virt_text_pos = 'right_align',
virt_text_repeat_linebreak = true,
})
screen:expect([[
aaaaaaaaaa{9:X}bbbbbbb {6:?}|
bbb{9:X}cccccccccc ^ {6:?}|
{0:~ }|*2
|
]])
api.nvim_input_mouse('left', 'press', '', 0, 0, 22)
screen:expect([[
aaaaaaaaaa{9:X}bbbbbb^b {6:?}|
bbb{9:X}cccccccccc {6:?}|
{0:~ }|*2
|
]])
api.nvim_input_mouse('left', 'press', '', 0, 1, 16)
screen:expect([[
aaaaaaaaaa{9:X}bbbbbbb {6:?}|
bbb{9:X}cccccccccc ^ {6:?}|
{0:~ }|*2
|
]])
end)
it('getmousepos() works correctly', function()
local winwidth = api.nvim_get_option_value('winwidth', {})
-- Set winwidth=1 so that window sizes don't change.