aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-07-24 18:16:53 +0800
committerGitHub <noreply@github.com>2023-07-24 18:16:53 +0800
commit5fb4c397a1da2737262ac7686666dc2596db50c2 (patch)
tree3cedc049a223c8f8135f16a00ddc1679dd1dddf7
parent01e273c340b5e51b593900c8feb894ba9a46c366 (diff)
downloadrneovim-5fb4c397a1da2737262ac7686666dc2596db50c2.tar.gz
rneovim-5fb4c397a1da2737262ac7686666dc2596db50c2.tar.bz2
rneovim-5fb4c397a1da2737262ac7686666dc2596db50c2.zip
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'.
-rw-r--r--src/nvim/mouse.c20
-rw-r--r--test/functional/ui/mouse_spec.lua62
2 files changed, 67 insertions, 15 deletions
diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c
index aca15eb0e2..d8341d2b10 100644
--- a/src/nvim/mouse.c
+++ b/src/nvim/mouse.c
@@ -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.
diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua
index 621855f051..d126e27cde 100644
--- a/test/functional/ui/mouse_spec.lua
+++ b/test/functional/ui/mouse_spec.lua
@@ -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([[