mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(mouse): correct dragged position in composed layout
This commit is contained in:
parent
3beea1fe1b
commit
810da1a702
@ -236,6 +236,11 @@ retnomove:
|
|||||||
redraw_curbuf_later(INVERTED); // delete the inversion
|
redraw_curbuf_later(INVERTED); // delete the inversion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (grid == 0) {
|
||||||
|
row -= curwin->w_grid_alloc.comp_row+curwin->w_grid.row_offset;
|
||||||
|
col -= curwin->w_grid_alloc.comp_col+curwin->w_grid.col_offset;
|
||||||
|
}
|
||||||
|
|
||||||
// When clicking beyond the end of the window, scroll the screen.
|
// When clicking beyond the end of the window, scroll the screen.
|
||||||
// Scroll by however many rows outside the window we are.
|
// Scroll by however many rows outside the window we are.
|
||||||
if (row < 0) {
|
if (row < 0) {
|
||||||
@ -476,7 +481,7 @@ win_T *mouse_find_win(int *gridp, int *rowp, int *colp)
|
|||||||
static win_T *mouse_find_grid_win(int *gridp, int *rowp, int *colp)
|
static win_T *mouse_find_grid_win(int *gridp, int *rowp, int *colp)
|
||||||
{
|
{
|
||||||
if (*gridp == msg_grid.handle) {
|
if (*gridp == msg_grid.handle) {
|
||||||
// rowp += msg_grid_pos; // PVS: dead store #11612
|
*rowp += msg_grid_pos;
|
||||||
*gridp = DEFAULT_GRID_HANDLE;
|
*gridp = DEFAULT_GRID_HANDLE;
|
||||||
} else if (*gridp > 1) {
|
} else if (*gridp > 1) {
|
||||||
win_T *wp = get_win_by_grid_handle(*gridp);
|
win_T *wp = get_win_by_grid_handle(*gridp);
|
||||||
|
@ -46,6 +46,7 @@ describe('float window', function()
|
|||||||
[24] = {foreground = Screen.colors.Black, background = Screen.colors.Grey80};
|
[24] = {foreground = Screen.colors.Black, background = Screen.colors.Grey80};
|
||||||
[25] = {blend = 100, background = Screen.colors.Gray0};
|
[25] = {blend = 100, background = Screen.colors.Gray0};
|
||||||
[26] = {blend = 80, background = Screen.colors.Gray0};
|
[26] = {blend = 80, background = Screen.colors.Gray0};
|
||||||
|
[27] = {background = Screen.colors.LightGray};
|
||||||
}
|
}
|
||||||
|
|
||||||
it('behavior', function()
|
it('behavior', function()
|
||||||
@ -6174,6 +6175,132 @@ describe('float window', function()
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it("left drag changes visual selection in float window", function()
|
||||||
|
local buf = meths.create_buf(false,false)
|
||||||
|
meths.buf_set_lines(buf, 0, -1, true, {'foo', 'bar'})
|
||||||
|
meths.open_win(buf, false, {relative='editor', width=20, height=3, row=2, col=5})
|
||||||
|
if multigrid then
|
||||||
|
screen:expect{grid=[[
|
||||||
|
## grid 1
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[3:----------------------------------------]|
|
||||||
|
## grid 2
|
||||||
|
^ |
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
## grid 3
|
||||||
|
|
|
||||||
|
## grid 5
|
||||||
|
{1:foo }|
|
||||||
|
{1:bar }|
|
||||||
|
{2:~ }|
|
||||||
|
]], float_pos={
|
||||||
|
[5] = {{id = 1002}, "NW", 1, 2, 5, true, 50};
|
||||||
|
}, win_viewport={
|
||||||
|
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
|
||||||
|
[5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 2};
|
||||||
|
}}
|
||||||
|
meths.input_mouse('left', 'press', '', 5, 0, 0)
|
||||||
|
screen:expect{grid=[[
|
||||||
|
## grid 1
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[3:----------------------------------------]|
|
||||||
|
## grid 2
|
||||||
|
|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
## grid 3
|
||||||
|
|
|
||||||
|
## grid 5
|
||||||
|
{1:^foo }|
|
||||||
|
{1:bar }|
|
||||||
|
{2:~ }|
|
||||||
|
]], float_pos={
|
||||||
|
[5] = {{id = 1002}, "NW", 1, 2, 5, true, 50};
|
||||||
|
}, win_viewport={
|
||||||
|
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
|
||||||
|
[5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 2};
|
||||||
|
}}
|
||||||
|
meths.input_mouse('left', 'drag', '', 5, 1, 2)
|
||||||
|
screen:expect{grid=[[
|
||||||
|
## grid 1
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[2:----------------------------------------]|
|
||||||
|
[3:----------------------------------------]|
|
||||||
|
## grid 2
|
||||||
|
|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }|
|
||||||
|
## grid 3
|
||||||
|
{3:-- VISUAL --} |
|
||||||
|
## grid 5
|
||||||
|
{27:foo}{1: }|
|
||||||
|
{27:ba}{1:^r }|
|
||||||
|
{2:~ }|
|
||||||
|
]], float_pos={
|
||||||
|
[5] = {{id = 1002}, "NW", 1, 2, 5, true, 50};
|
||||||
|
}, win_viewport={
|
||||||
|
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
|
||||||
|
[5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 2};
|
||||||
|
}}
|
||||||
|
else
|
||||||
|
screen:expect{grid=[[
|
||||||
|
^ |
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }{1:foo }{0: }|
|
||||||
|
{0:~ }{1:bar }{0: }|
|
||||||
|
{0:~ }{2:~ }{0: }|
|
||||||
|
{0:~ }|
|
||||||
|
|
|
||||||
|
]]}
|
||||||
|
|
||||||
|
meths.input_mouse('left', 'press', '', 0, 2, 5)
|
||||||
|
screen:expect{grid=[[
|
||||||
|
|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }{1:^foo }{0: }|
|
||||||
|
{0:~ }{1:bar }{0: }|
|
||||||
|
{0:~ }{2:~ }{0: }|
|
||||||
|
{0:~ }|
|
||||||
|
|
|
||||||
|
]]}
|
||||||
|
|
||||||
|
meths.input_mouse('left', 'drag', '', 0, 3, 7)
|
||||||
|
screen:expect{grid=[[
|
||||||
|
|
|
||||||
|
{0:~ }|
|
||||||
|
{0:~ }{27:foo}{1: }{0: }|
|
||||||
|
{0:~ }{27:ba}{1:^r }{0: }|
|
||||||
|
{0:~ }{2:~ }{0: }|
|
||||||
|
{0:~ }|
|
||||||
|
{3:-- VISUAL --} |
|
||||||
|
]]}
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
it("'winblend' option", function()
|
it("'winblend' option", function()
|
||||||
screen:try_resize(50,9)
|
screen:try_resize(50,9)
|
||||||
screen:set_default_attr_ids({
|
screen:set_default_attr_ids({
|
||||||
|
@ -585,6 +585,69 @@ describe('ui/mouse/input', function()
|
|||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('left drag changes visual selection in split layout', function()
|
||||||
|
screen:try_resize(53,14)
|
||||||
|
command('set mouse=a')
|
||||||
|
command('vsplit')
|
||||||
|
command('wincmd l')
|
||||||
|
command('below split')
|
||||||
|
command('enew')
|
||||||
|
feed('ifoo\nbar<esc>')
|
||||||
|
|
||||||
|
screen:expect{grid=[[
|
||||||
|
testing {4:│}testing |
|
||||||
|
mouse {4:│}mouse |
|
||||||
|
support and selection {4:│}support and selection |
|
||||||
|
{0:~ }{4:│}{0:~ }|
|
||||||
|
{0:~ }{4:│}{0:~ }|
|
||||||
|
{0:~ }{4:│[No Name] [+] }|
|
||||||
|
{0:~ }{4:│}foo{0:$} |
|
||||||
|
{0:~ }{4:│}ba^r{0:$} |
|
||||||
|
{0:~ }{4:│}{0:~ }|
|
||||||
|
{0:~ }{4:│}{0:~ }|
|
||||||
|
{0:~ }{4:│}{0:~ }|
|
||||||
|
{0:~ }{4:│}{0:~ }|
|
||||||
|
{4:[No Name] [+] }{5:[No Name] [+] }|
|
||||||
|
|
|
||||||
|
]]}
|
||||||
|
|
||||||
|
meths.input_mouse('left', 'press', '', 0, 6, 27)
|
||||||
|
screen:expect{grid=[[
|
||||||
|
testing {4:│}testing |
|
||||||
|
mouse {4:│}mouse |
|
||||||
|
support and selection {4:│}support and selection |
|
||||||
|
{0:~ }{4:│}{0:~ }|
|
||||||
|
{0:~ }{4:│}{0:~ }|
|
||||||
|
{0:~ }{4:│[No Name] [+] }|
|
||||||
|
{0:~ }{4:│}^foo{0:$} |
|
||||||
|
{0:~ }{4:│}bar{0:$} |
|
||||||
|
{0:~ }{4:│}{0:~ }|
|
||||||
|
{0:~ }{4:│}{0:~ }|
|
||||||
|
{0:~ }{4:│}{0:~ }|
|
||||||
|
{0:~ }{4:│}{0:~ }|
|
||||||
|
{4:[No Name] [+] }{5:[No Name] [+] }|
|
||||||
|
|
|
||||||
|
]]}
|
||||||
|
meths.input_mouse('left', 'drag', '', 0, 7, 30)
|
||||||
|
|
||||||
|
screen:expect{grid=[[
|
||||||
|
testing {4:│}testing |
|
||||||
|
mouse {4:│}mouse |
|
||||||
|
support and selection {4:│}support and selection |
|
||||||
|
{0:~ }{4:│}{0:~ }|
|
||||||
|
{0:~ }{4:│}{0:~ }|
|
||||||
|
{0:~ }{4:│[No Name] [+] }|
|
||||||
|
{0:~ }{4:│}{1:foo}{3:$} |
|
||||||
|
{0:~ }{4:│}{1:bar}{0:^$} |
|
||||||
|
{0:~ }{4:│}{0:~ }|
|
||||||
|
{0:~ }{4:│}{0:~ }|
|
||||||
|
{0:~ }{4:│}{0:~ }|
|
||||||
|
{0:~ }{4:│}{0:~ }|
|
||||||
|
{4:[No Name] [+] }{5:[No Name] [+] }|
|
||||||
|
{2:-- VISUAL --} |
|
||||||
|
]]}
|
||||||
|
end)
|
||||||
|
|
||||||
it('two clicks will select the word and enter VISUAL', function()
|
it('two clicks will select the word and enter VISUAL', function()
|
||||||
feed('<LeftMouse><2,2><LeftMouse><2,2>')
|
feed('<LeftMouse><2,2><LeftMouse><2,2>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
|
Loading…
Reference in New Issue
Block a user