[RDY] Fix click on foldcolumn if it has tabline (#13982)
* Fix click on foldcolumn if it has tabline * Fixes to correctly determine if tablie was clicked when multigrid is enabled * Separate foldcolumn checks into functions * Add test case for click on foldcolumn with split window * Fix foldcolumn click used nvim_input() on multigrid enabled
This commit is contained in:
parent
df4440024b
commit
f2fc44d50b
|
@ -72,9 +72,7 @@ int jump_to_mouse(int flags,
|
|||
int row = mouse_row;
|
||||
int col = mouse_col;
|
||||
int grid = mouse_grid;
|
||||
int mouse_char;
|
||||
int fdc = 0;
|
||||
ScreenGrid *gp = &default_grid;
|
||||
|
||||
mouse_past_bottom = false;
|
||||
mouse_past_eol = false;
|
||||
|
@ -303,25 +301,6 @@ retnomove:
|
|||
}
|
||||
}
|
||||
|
||||
// Remember the character under the mouse, might be one of foldclose or
|
||||
// foldopen fillchars in the fold column.
|
||||
if (ui_has(kUIMultigrid)) {
|
||||
gp = &curwin->w_grid;
|
||||
}
|
||||
if (row >= 0 && row < Rows && col >= 0 && col <= Columns
|
||||
&& gp->chars != NULL) {
|
||||
mouse_char = utf_ptr2char(gp->chars[gp->line_offset[row]
|
||||
+ (unsigned)col]);
|
||||
} else {
|
||||
mouse_char = ' ';
|
||||
}
|
||||
|
||||
// Check for position outside of the fold column.
|
||||
if (curwin->w_p_rl ? col < curwin->w_width_inner - fdc :
|
||||
col >= fdc + (cmdwin_type == 0 ? 0 : 1)) {
|
||||
mouse_char = ' ';
|
||||
}
|
||||
|
||||
// compute the position in the buffer line from the posn on the screen
|
||||
if (mouse_comp_pos(curwin, &row, &col, &curwin->w_cursor.lnum)) {
|
||||
mouse_past_bottom = true;
|
||||
|
@ -362,11 +341,7 @@ retnomove:
|
|||
count |= CURSOR_MOVED; // Cursor has moved
|
||||
}
|
||||
|
||||
if (mouse_char == curwin->w_p_fcs_chars.foldclosed) {
|
||||
count |= MOUSE_FOLD_OPEN;
|
||||
} else if (mouse_char != ' ') {
|
||||
count |= MOUSE_FOLD_CLOSE;
|
||||
}
|
||||
count |= mouse_check_fold();
|
||||
|
||||
return count;
|
||||
}
|
||||
|
@ -738,3 +713,47 @@ static int mouse_adjust_click(win_T *wp, int row, int col)
|
|||
|
||||
return col + nudge;
|
||||
}
|
||||
|
||||
// Check clicked cell is foldcolumn
|
||||
int mouse_check_fold(void)
|
||||
{
|
||||
int grid = mouse_grid;
|
||||
int row = mouse_row;
|
||||
int col = mouse_col;
|
||||
int mouse_char = ' ';
|
||||
|
||||
win_T *wp;
|
||||
|
||||
wp = mouse_find_win(&grid, &row, &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;
|
||||
int fdc = win_fdccol_count(wp);
|
||||
|
||||
row = multigrid && mouse_grid == 0 ? row : mouse_row;
|
||||
col = multigrid && mouse_grid == 0 ? col : mouse_col;
|
||||
|
||||
// Remember the character under the mouse, might be one of foldclose or
|
||||
// foldopen fillchars in the fold column.
|
||||
if (gp->chars != NULL) {
|
||||
mouse_char = utf_ptr2char(gp->chars[gp->line_offset[row]
|
||||
+ (unsigned)col]);
|
||||
}
|
||||
|
||||
// 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)) {
|
||||
mouse_char = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
if (mouse_char == wp->w_p_fcs_chars.foldclosed) {
|
||||
return MOUSE_FOLD_OPEN;
|
||||
} else if (mouse_char != ' ') {
|
||||
return MOUSE_FOLD_CLOSE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -2404,8 +2404,8 @@ do_mouse (
|
|||
|
||||
start_visual.lnum = 0;
|
||||
|
||||
/* Check for clicking in the tab page line. */
|
||||
if (mouse_row == 0 && firstwin->w_winrow > 0) {
|
||||
// Check for clicking in the tab page line.
|
||||
if (mouse_grid <= 1 && mouse_row == 0 && firstwin->w_winrow > 0) {
|
||||
if (is_drag) {
|
||||
if (in_tab_line) {
|
||||
move_tab_to_mouse();
|
||||
|
|
|
@ -38,7 +38,9 @@ describe("folded lines", function()
|
|||
[6] = {background = Screen.colors.Yellow},
|
||||
[7] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray},
|
||||
[8] = {foreground = Screen.colors.Brown },
|
||||
[9] = {bold = true, foreground = Screen.colors.Brown}
|
||||
[9] = {bold = true, foreground = Screen.colors.Brown},
|
||||
[10] = {background = Screen.colors.LightGrey, underline = true},
|
||||
[11] = {bold=true},
|
||||
})
|
||||
end)
|
||||
|
||||
|
@ -290,6 +292,369 @@ describe("folded lines", function()
|
|||
end
|
||||
end)
|
||||
|
||||
it("works with split", function()
|
||||
insert([[
|
||||
aa
|
||||
bb
|
||||
cc
|
||||
dd
|
||||
ee
|
||||
ff]])
|
||||
feed_command('2')
|
||||
command("set foldcolumn=1")
|
||||
feed('zf3j')
|
||||
feed_command('1')
|
||||
feed('zf2j')
|
||||
feed('zO')
|
||||
feed_command("rightbelow new")
|
||||
insert([[
|
||||
aa
|
||||
bb
|
||||
cc
|
||||
dd
|
||||
ee
|
||||
ff]])
|
||||
feed_command('2')
|
||||
command("set foldcolumn=1")
|
||||
feed('zf3j')
|
||||
feed_command('1')
|
||||
feed('zf2j')
|
||||
if multigrid then
|
||||
meths.input_mouse('left', 'press', '', 4, 0, 0)
|
||||
screen:expect([[
|
||||
## grid 1
|
||||
[2:---------------------------------------------]|
|
||||
[2:---------------------------------------------]|
|
||||
{2:[No Name] [+] }|
|
||||
[4:---------------------------------------------]|
|
||||
[4:---------------------------------------------]|
|
||||
[4:---------------------------------------------]|
|
||||
{3:[No Name] [+] }|
|
||||
[3:---------------------------------------------]|
|
||||
## grid 2
|
||||
{7:-}aa |
|
||||
{7:-}bb |
|
||||
## grid 3
|
||||
:1 |
|
||||
## grid 4
|
||||
{7:-}^aa |
|
||||
{7:+}{5:+--- 4 lines: bb···························}|
|
||||
{7:│}ff |
|
||||
]])
|
||||
else
|
||||
meths.input_mouse('left', 'press', '', 0, 3, 0)
|
||||
screen:expect([[
|
||||
{7:-}aa |
|
||||
{7:-}bb |
|
||||
{2:[No Name] [+] }|
|
||||
{7:-}^aa |
|
||||
{7:+}{5:+--- 4 lines: bb···························}|
|
||||
{7:│}ff |
|
||||
{3:[No Name] [+] }|
|
||||
:1 |
|
||||
]])
|
||||
end
|
||||
|
||||
if multigrid then
|
||||
meths.input_mouse('left', 'press', '', 4, 1, 0)
|
||||
screen:expect([[
|
||||
## grid 1
|
||||
[2:---------------------------------------------]|
|
||||
[2:---------------------------------------------]|
|
||||
{2:[No Name] [+] }|
|
||||
[4:---------------------------------------------]|
|
||||
[4:---------------------------------------------]|
|
||||
[4:---------------------------------------------]|
|
||||
{3:[No Name] [+] }|
|
||||
[3:---------------------------------------------]|
|
||||
## grid 2
|
||||
{7:-}aa |
|
||||
{7:-}bb |
|
||||
## grid 3
|
||||
:1 |
|
||||
## grid 4
|
||||
{7:-}^aa |
|
||||
{7:-}bb |
|
||||
{7:2}cc |
|
||||
]])
|
||||
else
|
||||
meths.input_mouse('left', 'press', '', 0, 4, 0)
|
||||
screen:expect([[
|
||||
{7:-}aa |
|
||||
{7:-}bb |
|
||||
{2:[No Name] [+] }|
|
||||
{7:-}^aa |
|
||||
{7:-}bb |
|
||||
{7:2}cc |
|
||||
{3:[No Name] [+] }|
|
||||
:1 |
|
||||
]])
|
||||
end
|
||||
|
||||
if multigrid then
|
||||
meths.input_mouse('left', 'press', '', 2, 1, 0)
|
||||
screen:expect([[
|
||||
## grid 1
|
||||
[2:---------------------------------------------]|
|
||||
[2:---------------------------------------------]|
|
||||
{3:[No Name] [+] }|
|
||||
[4:---------------------------------------------]|
|
||||
[4:---------------------------------------------]|
|
||||
[4:---------------------------------------------]|
|
||||
{2:[No Name] [+] }|
|
||||
[3:---------------------------------------------]|
|
||||
## grid 2
|
||||
{7:-}aa |
|
||||
{7:+}{5:^+--- 4 lines: bb···························}|
|
||||
## grid 3
|
||||
:1 |
|
||||
## grid 4
|
||||
{7:-}aa |
|
||||
{7:-}bb |
|
||||
{7:2}cc |
|
||||
]])
|
||||
else
|
||||
meths.input_mouse('left', 'press', '', 0, 1, 0)
|
||||
screen:expect([[
|
||||
{7:-}aa |
|
||||
{7:+}{5:^+--- 4 lines: bb···························}|
|
||||
{3:[No Name] [+] }|
|
||||
{7:-}aa |
|
||||
{7:-}bb |
|
||||
{7:2}cc |
|
||||
{2:[No Name] [+] }|
|
||||
:1 |
|
||||
]])
|
||||
end
|
||||
|
||||
if multigrid then
|
||||
meths.input_mouse('left', 'press', '', 2, 0, 0)
|
||||
screen:expect([[
|
||||
## grid 1
|
||||
[2:---------------------------------------------]|
|
||||
[2:---------------------------------------------]|
|
||||
{3:[No Name] [+] }|
|
||||
[4:---------------------------------------------]|
|
||||
[4:---------------------------------------------]|
|
||||
[4:---------------------------------------------]|
|
||||
{2:[No Name] [+] }|
|
||||
[3:---------------------------------------------]|
|
||||
## grid 2
|
||||
{7:+}{5:^+-- 6 lines: aa····························}|
|
||||
{1:~ }|
|
||||
## grid 3
|
||||
:1 |
|
||||
## grid 4
|
||||
{7:-}aa |
|
||||
{7:-}bb |
|
||||
{7:2}cc |
|
||||
]])
|
||||
else
|
||||
meths.input_mouse('left', 'press', '', 0, 0, 0)
|
||||
screen:expect([[
|
||||
{7:+}{5:^+-- 6 lines: aa····························}|
|
||||
{1:~ }|
|
||||
{3:[No Name] [+] }|
|
||||
{7:-}aa |
|
||||
{7:-}bb |
|
||||
{7:2}cc |
|
||||
{2:[No Name] [+] }|
|
||||
:1 |
|
||||
]])
|
||||
end
|
||||
end)
|
||||
|
||||
it("works with tab", function()
|
||||
insert([[
|
||||
aa
|
||||
bb
|
||||
cc
|
||||
dd
|
||||
ee
|
||||
ff]])
|
||||
feed_command('2')
|
||||
command("set foldcolumn=2")
|
||||
feed('zf3j')
|
||||
feed_command('1')
|
||||
feed('zf2j')
|
||||
feed('zO')
|
||||
feed_command("tab split")
|
||||
if multigrid then
|
||||
meths.input_mouse('left', 'press', '', 4, 1, 1)
|
||||
screen:expect([[
|
||||
## grid 1
|
||||
{10: + [No Name] }{11: + [No Name] }{2: }{10:X}|
|
||||
[4:---------------------------------------------]|
|
||||
[4:---------------------------------------------]|
|
||||
[4:---------------------------------------------]|
|
||||
[4:---------------------------------------------]|
|
||||
[4:---------------------------------------------]|
|
||||
[4:---------------------------------------------]|
|
||||
[3:---------------------------------------------]|
|
||||
## grid 2 (hidden)
|
||||
{7:- }aa |
|
||||
{7:│-}bb |
|
||||
{7:││}cc |
|
||||
{7:││}dd |
|
||||
{7:││}ee |
|
||||
{7:│ }ff |
|
||||
{1:~ }|
|
||||
## grid 3
|
||||
:tab split |
|
||||
## grid 4
|
||||
{7:- }^aa |
|
||||
{7:│+}{5:+--- 4 lines: bb··························}|
|
||||
{7:│ }ff |
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
]])
|
||||
else
|
||||
meths.input_mouse('left', 'press', '', 0, 2, 1)
|
||||
screen:expect([[
|
||||
{10: + [No Name] }{11: + [No Name] }{2: }{10:X}|
|
||||
{7:- }^aa |
|
||||
{7:│+}{5:+--- 4 lines: bb··························}|
|
||||
{7:│ }ff |
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
:tab split |
|
||||
]])
|
||||
end
|
||||
|
||||
if multigrid then
|
||||
meths.input_mouse('left', 'press', '', 4, 0, 0)
|
||||
screen:expect([[
|
||||
## grid 1
|
||||
{10: + [No Name] }{11: + [No Name] }{2: }{10:X}|
|
||||
[4:---------------------------------------------]|
|
||||
[4:---------------------------------------------]|
|
||||
[4:---------------------------------------------]|
|
||||
[4:---------------------------------------------]|
|
||||
[4:---------------------------------------------]|
|
||||
[4:---------------------------------------------]|
|
||||
[3:---------------------------------------------]|
|
||||
## grid 2 (hidden)
|
||||
{7:- }aa |
|
||||
{7:│-}bb |
|
||||
{7:││}cc |
|
||||
{7:││}dd |
|
||||
{7:││}ee |
|
||||
{7:│ }ff |
|
||||
{1:~ }|
|
||||
## grid 3
|
||||
:tab split |
|
||||
## grid 4
|
||||
{7:+ }{5:^+-- 6 lines: aa···························}|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
]])
|
||||
else
|
||||
meths.input_mouse('left', 'press', '', 0, 1, 0)
|
||||
screen:expect([[
|
||||
{10: + [No Name] }{11: + [No Name] }{2: }{10:X}|
|
||||
{7:+ }{5:^+-- 6 lines: aa···························}|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
:tab split |
|
||||
]])
|
||||
end
|
||||
|
||||
feed_command("tabnext")
|
||||
if multigrid then
|
||||
meths.input_mouse('left', 'press', '', 2, 1, 1)
|
||||
screen:expect([[
|
||||
## grid 1
|
||||
{11: + [No Name] }{10: + [No Name] }{2: }{10:X}|
|
||||
[2:---------------------------------------------]|
|
||||
[2:---------------------------------------------]|
|
||||
[2:---------------------------------------------]|
|
||||
[2:---------------------------------------------]|
|
||||
[2:---------------------------------------------]|
|
||||
[2:---------------------------------------------]|
|
||||
[3:---------------------------------------------]|
|
||||
## grid 2
|
||||
{7:- }^aa |
|
||||
{7:│+}{5:+--- 4 lines: bb··························}|
|
||||
{7:│ }ff |
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
## grid 3
|
||||
:tabnext |
|
||||
## grid 4 (hidden)
|
||||
{7:+ }{5:+-- 6 lines: aa···························}|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
]])
|
||||
else
|
||||
meths.input_mouse('left', 'press', '', 0, 2, 1)
|
||||
screen:expect([[
|
||||
{11: + [No Name] }{10: + [No Name] }{2: }{10:X}|
|
||||
{7:- }^aa |
|
||||
{7:│+}{5:+--- 4 lines: bb··························}|
|
||||
{7:│ }ff |
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
:tabnext |
|
||||
]])
|
||||
end
|
||||
|
||||
if multigrid then
|
||||
meths.input_mouse('left', 'press', '', 2, 0, 0)
|
||||
screen:expect([[
|
||||
## grid 1
|
||||
{11: + [No Name] }{10: + [No Name] }{2: }{10:X}|
|
||||
[2:---------------------------------------------]|
|
||||
[2:---------------------------------------------]|
|
||||
[2:---------------------------------------------]|
|
||||
[2:---------------------------------------------]|
|
||||
[2:---------------------------------------------]|
|
||||
[2:---------------------------------------------]|
|
||||
[3:---------------------------------------------]|
|
||||
## grid 2
|
||||
{7:+ }{5:^+-- 6 lines: aa···························}|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
## grid 3
|
||||
:tabnext |
|
||||
## grid 4 (hidden)
|
||||
{7:+ }{5:+-- 6 lines: aa···························}|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
]])
|
||||
else
|
||||
meths.input_mouse('left', 'press', '', 0, 1, 0)
|
||||
screen:expect([[
|
||||
{11: + [No Name] }{10: + [No Name] }{2: }{10:X}|
|
||||
{7:+ }{5:^+-- 6 lines: aa···························}|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
:tabnext |
|
||||
]])
|
||||
end
|
||||
end)
|
||||
|
||||
it("works with multibyte text", function()
|
||||
-- Currently the only allowed value of 'maxcombine'
|
||||
eq(6, meths.get_option('maxcombine'))
|
||||
|
|
Loading…
Reference in New Issue