mirror of
https://github.com/neovim/neovim
synced 2025-07-16 09:11:51 +00:00
fix(multigrid): #15075 mouse events crash neovim
This commit is contained in:
@ -723,14 +723,20 @@ int mouse_check_fold(void)
|
|||||||
int click_row = mouse_row;
|
int click_row = mouse_row;
|
||||||
int click_col = mouse_col;
|
int click_col = mouse_col;
|
||||||
int mouse_char = ' ';
|
int mouse_char = ' ';
|
||||||
|
int max_row = Rows;
|
||||||
|
int max_col = Columns;
|
||||||
|
int multigrid = ui_has(kUIMultigrid);
|
||||||
|
|
||||||
win_T *wp;
|
win_T *wp;
|
||||||
|
|
||||||
wp = mouse_find_win(&click_grid, &click_row, &click_col);
|
wp = mouse_find_win(&click_grid, &click_row, &click_col);
|
||||||
|
if (wp && multigrid) {
|
||||||
|
max_row = wp->w_grid_alloc.Rows;
|
||||||
|
max_col = wp->w_grid_alloc.Columns;
|
||||||
|
}
|
||||||
|
|
||||||
if (wp && mouse_row >= 0 && mouse_row < Rows
|
if (wp && mouse_row >= 0 && mouse_row < max_row
|
||||||
&& mouse_col >= 0 && mouse_col <= Columns) {
|
&& mouse_col >= 0 && mouse_col < max_col) {
|
||||||
int multigrid = ui_has(kUIMultigrid);
|
|
||||||
ScreenGrid *gp = multigrid ? &wp->w_grid_alloc : &default_grid;
|
ScreenGrid *gp = multigrid ? &wp->w_grid_alloc : &default_grid;
|
||||||
int fdc = win_fdccol_count(wp);
|
int fdc = win_fdccol_count(wp);
|
||||||
int row = multigrid && mouse_grid == 0 ? click_row : mouse_row;
|
int row = multigrid && mouse_grid == 0 ? click_row : mouse_row;
|
||||||
|
@ -2220,4 +2220,92 @@ describe('ext_multigrid', function()
|
|||||||
[4] = {win = {id = 1001}, topline = 4, botline = 8, curline = 4, curcol = 38},
|
[4] = {win = {id = 1001}, topline = 4, botline = 8, curline = 4, curcol = 38},
|
||||||
}}
|
}}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('does not crash when dragging mouse across grid boundary', function()
|
||||||
|
screen:try_resize(48, 8)
|
||||||
|
screen:expect{grid=[[
|
||||||
|
## grid 1
|
||||||
|
[2:------------------------------------------------]|
|
||||||
|
[2:------------------------------------------------]|
|
||||||
|
[2:------------------------------------------------]|
|
||||||
|
[2:------------------------------------------------]|
|
||||||
|
[2:------------------------------------------------]|
|
||||||
|
[2:------------------------------------------------]|
|
||||||
|
{11:[No Name] }|
|
||||||
|
[3:------------------------------------------------]|
|
||||||
|
## grid 2
|
||||||
|
^ |
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
## grid 3
|
||||||
|
|
|
||||||
|
]], win_viewport={
|
||||||
|
[2] = {win = { id = 1000 }, topline = 0, botline = 2, curline = 0, curcol = 0}
|
||||||
|
}}
|
||||||
|
insert([[
|
||||||
|
Lorem ipsum dolor sit amet, consectetur
|
||||||
|
adipisicing elit, sed do eiusmod tempor
|
||||||
|
incididunt ut labore et dolore magna aliqua.
|
||||||
|
Ut enim ad minim veniam, quis nostrud
|
||||||
|
exercitation ullamco laboris nisi ut aliquip ex
|
||||||
|
ea commodo consequat. Duis aute irure dolor in
|
||||||
|
reprehenderit in voluptate velit esse cillum
|
||||||
|
dolore eu fugiat nulla pariatur. Excepteur sint
|
||||||
|
occaecat cupidatat non proident, sunt in culpa
|
||||||
|
qui officia deserunt mollit anim id est
|
||||||
|
laborum.]])
|
||||||
|
|
||||||
|
screen:expect{grid=[[
|
||||||
|
## grid 1
|
||||||
|
[2:------------------------------------------------]|
|
||||||
|
[2:------------------------------------------------]|
|
||||||
|
[2:------------------------------------------------]|
|
||||||
|
[2:------------------------------------------------]|
|
||||||
|
[2:------------------------------------------------]|
|
||||||
|
[2:------------------------------------------------]|
|
||||||
|
{11:[No Name] [+] }|
|
||||||
|
[3:------------------------------------------------]|
|
||||||
|
## grid 2
|
||||||
|
ea commodo consequat. Duis aute irure dolor in |
|
||||||
|
reprehenderit in voluptate velit esse cillum |
|
||||||
|
dolore eu fugiat nulla pariatur. Excepteur sint |
|
||||||
|
occaecat cupidatat non proident, sunt in culpa |
|
||||||
|
qui officia deserunt mollit anim id est |
|
||||||
|
laborum^. |
|
||||||
|
## grid 3
|
||||||
|
|
|
||||||
|
]], win_viewport={
|
||||||
|
[2] = {win = {id = 1000}, topline = 5, botline = 11, curline = 10, curcol = 7},
|
||||||
|
}}
|
||||||
|
|
||||||
|
meths.input_mouse('left', 'press', '', 1,5, 1)
|
||||||
|
poke_eventloop()
|
||||||
|
meths.input_mouse('left', 'drag', '', 1, 6, 1)
|
||||||
|
|
||||||
|
screen:expect{grid=[[
|
||||||
|
## grid 1
|
||||||
|
[2:------------------------------------------------]|
|
||||||
|
[2:------------------------------------------------]|
|
||||||
|
[2:------------------------------------------------]|
|
||||||
|
[2:------------------------------------------------]|
|
||||||
|
[2:------------------------------------------------]|
|
||||||
|
[2:------------------------------------------------]|
|
||||||
|
{11:[No Name] [+] }|
|
||||||
|
[3:------------------------------------------------]|
|
||||||
|
## grid 2
|
||||||
|
reprehenderit in voluptate velit esse cillum |
|
||||||
|
dolore eu fugiat nulla pariatur. Excepteur sint |
|
||||||
|
occaecat cupidatat non proident, sunt in culpa |
|
||||||
|
qui officia deserunt mollit anim id est |
|
||||||
|
l^aborum. |
|
||||||
|
{1:~ }|
|
||||||
|
## grid 3
|
||||||
|
{7:-- VISUAL --} |
|
||||||
|
]], win_viewport={
|
||||||
|
[2] = {win = {id = 1000}, topline = 6, botline = 12, curline = 10, curcol = 1},
|
||||||
|
}}
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user