fix(mouse): drag vsep of window with 'statuscolumn' (#24462)

Problem:    Cannot drag a vertical separator to the right of a window
            whose 'statuscolumn' is wider than itself.
Solution:   Never treat a click on a vertical separator as a click on
            'statuscolumn'.
This commit is contained in:
zeertzjq 2023-07-24 18:16:53 +08:00 committed by GitHub
parent 01e273c340
commit 5fb4c397a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 67 additions and 15 deletions

View File

@ -1107,21 +1107,11 @@ retnomove:
}
bool below_window = grid == DEFAULT_GRID_HANDLE && row + wp->w_winbar_height >= wp->w_height;
on_status_line = (below_window)
? row + wp->w_winbar_height - wp->w_height + 1 == 1
: false;
on_winbar = (row == -1)
? wp->w_winbar_height != 0
: false;
on_statuscol = !below_window && !on_status_line && !on_winbar && col < win_col_off(wp)
? *wp->w_p_stc != NUL
: false;
on_sep_line = grid == DEFAULT_GRID_HANDLE && col >= wp->w_width
? col - wp->w_width + 1 == 1
: false;
on_status_line = below_window && row + wp->w_winbar_height - wp->w_height + 1 == 1;
on_sep_line = grid == DEFAULT_GRID_HANDLE && col >= wp->w_width && col - wp->w_width + 1 == 1;
on_winbar = row == -1 && wp->w_winbar_height != 0;
on_statuscol = !below_window && !on_status_line && !on_sep_line && !on_winbar
&& *wp->w_p_stc != NUL && col < win_col_off(wp);
// The rightmost character of the status line might be a vertical
// separator character if there is no connecting window to the right.

View File

@ -3,6 +3,7 @@ local Screen = require('test.functional.ui.screen')
local clear, feed, meths = helpers.clear, helpers.feed, helpers.meths
local insert, feed_command = helpers.insert, helpers.feed_command
local eq, funcs = helpers.eq, helpers.funcs
local poke_eventloop = helpers.poke_eventloop
local command = helpers.command
local exec = helpers.exec
@ -32,6 +33,7 @@ describe('ui/mouse/input', function()
[5] = {bold = true, reverse = true},
[6] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
[7] = {bold = true, foreground = Screen.colors.SeaGreen4},
[8] = {foreground = Screen.colors.Brown},
})
command("set mousemodel=extend")
feed('itesting<cr>mouse<cr>support and selection<esc>')
@ -798,6 +800,66 @@ describe('ui/mouse/input', function()
feed('<cr>')
end)
it('dragging vertical separator', function()
screen:try_resize(45, 5)
command('setlocal nowrap')
local oldwin = meths.get_current_win().id
command('rightbelow vnew')
screen:expect([[
testing {0:^$} |
mouse {0:~ }|
support and selection {0:~ }|
{4:[No Name] [+] }{5:[No Name] }|
|
]])
meths.input_mouse('left', 'press', '', 0, 0, 22)
poke_eventloop()
meths.input_mouse('left', 'drag', '', 0, 1, 12)
screen:expect([[
testing {0:^$} |
mouse {0:~ }|
support and {0:~ }|
{4:< Name] [+] }{5:[No Name] }|
|
]])
meths.input_mouse('left', 'drag', '', 0, 2, 2)
screen:expect([[
te{0:^$} |
mo{0:~ }|
su{0:~ }|
{4:< }{5:[No Name] }|
|
]])
meths.input_mouse('left', 'release', '', 0, 2, 2)
meths.set_option_value('statuscolumn', 'foobar', { win = oldwin })
screen:expect([[
{8:fo}{0:^$} |
{8:fo}{0:~ }|
{8:fo}{0:~ }|
{4:< }{5:[No Name] }|
|
]])
meths.input_mouse('left', 'press', '', 0, 0, 2)
poke_eventloop()
meths.input_mouse('left', 'drag', '', 0, 1, 12)
screen:expect([[
{8:foobar}testin{0:^$} |
{8:foobar}mouse {0:~ }|
{8:foobar}suppor{0:~ }|
{4:< Name] [+] }{5:[No Name] }|
|
]])
meths.input_mouse('left', 'drag', '', 0, 2, 22)
screen:expect([[
{8:foobar}testing {0:^$} |
{8:foobar}mouse {0:~ }|
{8:foobar}support and sele{0:~ }|
{4:[No Name] [+] }{5:[No Name] }|
|
]])
meths.input_mouse('left', 'release', '', 0, 2, 22)
end)
local function wheel(use_api)
feed('ggdG')
insert([[