fix(mouse.c): fix mouse drag positions on multigrid #12667

Currently, multigrid mouse drag positions are handled incorrectly if the
drag event is not in the top left grid. Fix this by not adjusting the
position of the event in jump_to_mouse.

related: #15091
This commit is contained in:
Ville Hakulinen 2021-09-10 17:24:41 +03:00 committed by GitHub
parent c58ee4ef7f
commit 0dcfd0e8d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 61 additions and 4 deletions

View File

@ -228,10 +228,6 @@ retnomove:
redraw_curbuf_later(INVERTED); // delete the inversion
}
row -= curwin->w_winrow;
col -= curwin->w_wincol;
// When clicking beyond the end of the window, scroll the screen.
// Scroll by however many rows outside the window we are.
if (row < 0) {

View File

@ -34,6 +34,7 @@ describe('ext_multigrid', function()
[17] = {background = Screen.colors.LightGrey, underline = true, bold = true, foreground = Screen.colors.Magenta},
[18] = {bold = true, foreground = Screen.colors.Magenta},
[19] = {foreground = Screen.colors.Brown},
[20] = {background = Screen.colors.LightGrey},
})
end)
@ -2034,6 +2035,66 @@ describe('ext_multigrid', function()
]]}
end)
it('supports mouse drag with mouse=a', function()
command('set mouse=a')
command('vsplit')
command('wincmd l')
command('split')
command('enew')
feed('ifoo\nbar<esc>')
meths.input_mouse('left', 'press', '', 5, 0, 0)
poke_eventloop()
meths.input_mouse('left', 'drag', '', 5, 1, 2)
screen:expect{grid=[[
## grid 1
[4:--------------------------]{12:│}[5:--------------------------]|
[4:--------------------------]{12:│}[5:--------------------------]|
[4:--------------------------]{12:│}[5:--------------------------]|
[4:--------------------------]{12:│}[5:--------------------------]|
[4:--------------------------]{12:│}[5:--------------------------]|
[4:--------------------------]{12:│}[5:--------------------------]|
[4:--------------------------]{12:│}{11:[No Name] [+] }|
[4:--------------------------]{12:│}[2:--------------------------]|
[4:--------------------------]{12:│}[2:--------------------------]|
[4:--------------------------]{12:│}[2:--------------------------]|
[4:--------------------------]{12:│}[2:--------------------------]|
[4:--------------------------]{12:│}[2:--------------------------]|
{12:[No Name] [No Name] }|
[3:-----------------------------------------------------]|
## grid 2
|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
## grid 3
{7:-- VISUAL --} |
## grid 4
|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
## grid 5
{20:foo} |
{20:ba}^r |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
]]}
end)
it('has viewport information', function()
screen:try_resize(48, 8)
screen:expect{grid=[[