aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/mouse.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/mouse.c')
-rw-r--r--src/nvim/mouse.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c
index f28658aa29..4c0339e5f4 100644
--- a/src/nvim/mouse.c
+++ b/src/nvim/mouse.c
@@ -470,21 +470,21 @@ static win_T *mouse_find_grid_win(int *gridp, int *rowp, int *colp)
*gridp = DEFAULT_GRID_HANDLE;
} else if (*gridp > 1) {
win_T *wp = get_win_by_grid_handle(*gridp);
- if (wp && wp->w_grid.chars
+ if (wp && wp->w_grid_alloc.chars
&& !(wp->w_floating && !wp->w_float_config.focusable)) {
- *rowp = MIN(*rowp, wp->w_grid.Rows-1);
- *colp = MIN(*colp, wp->w_grid.Columns-1);
+ *rowp = MIN(*rowp-wp->w_grid.row_offset, wp->w_grid.Rows-1);
+ *colp = MIN(*colp-wp->w_grid.col_offset, wp->w_grid.Columns-1);
return wp;
}
} else if (*gridp == 0) {
ScreenGrid *grid = ui_comp_mouse_focus(*rowp, *colp);
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
- if (&wp->w_grid != grid) {
+ if (&wp->w_grid_alloc != grid) {
continue;
}
*gridp = grid->handle;
- *rowp -= grid->comp_row;
- *colp -= grid->comp_col;
+ *rowp -= grid->comp_row+wp->w_grid.row_offset;
+ *colp -= grid->comp_col+wp->w_grid.col_offset;
return wp;
}
@@ -717,23 +717,22 @@ static int mouse_adjust_click(win_T *wp, int row, int col)
// Check clicked cell is foldcolumn
int mouse_check_fold(void)
{
- int grid = mouse_grid;
- int row = mouse_row;
- int col = mouse_col;
+ int click_grid = mouse_grid;
+ int click_row = mouse_row;
+ int click_col = mouse_col;
int mouse_char = ' ';
win_T *wp;
- wp = mouse_find_win(&grid, &row, &col);
+ wp = mouse_find_win(&click_grid, &click_row, &click_col);
if (wp && mouse_row >= 0 && mouse_row < Rows
&& mouse_col >= 0 && mouse_col <= Columns) {
int multigrid = ui_has(kUIMultigrid);
- ScreenGrid *gp = multigrid ? &wp->w_grid : &default_grid;
+ ScreenGrid *gp = multigrid ? &wp->w_grid_alloc : &default_grid;
int fdc = win_fdccol_count(wp);
-
- row = multigrid && mouse_grid == 0 ? row : mouse_row;
- col = multigrid && mouse_grid == 0 ? col : mouse_col;
+ int row = multigrid && mouse_grid == 0 ? click_row : mouse_row;
+ int col = multigrid && mouse_grid == 0 ? click_col : mouse_col;
// Remember the character under the mouse, might be one of foldclose or
// foldopen fillchars in the fold column.
@@ -743,13 +742,13 @@ int mouse_check_fold(void)
}
// Check for position outside of the fold column.
- if (wp->w_p_rl ? col < wp->w_width_inner - fdc :
- col >= fdc + (cmdwin_type == 0 ? 0 : 1)) {
+ if (wp->w_p_rl ? click_col < wp->w_width_inner - fdc :
+ click_col >= fdc + (cmdwin_type == 0 ? 0 : 1)) {
mouse_char = ' ';
}
}
- if (mouse_char == wp->w_p_fcs_chars.foldclosed) {
+ if (wp && mouse_char == wp->w_p_fcs_chars.foldclosed) {
return MOUSE_FOLD_OPEN;
} else if (mouse_char != ' ') {
return MOUSE_FOLD_CLOSE;