mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
fix(mouse): handle folded lines with virt_lines attached to line above
This commit is contained in:
@@ -1300,14 +1300,13 @@ retnomove:
|
|||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
|
|
||||||
if (hasFolding(curwin->w_topline, NULL, &curwin->w_topline)
|
|
||||||
&& curwin->w_topline == curbuf->b_ml.ml_line_count) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (curwin->w_topfill > 0) {
|
if (curwin->w_topfill > 0) {
|
||||||
curwin->w_topfill--;
|
curwin->w_topfill--;
|
||||||
} else {
|
} else {
|
||||||
|
if (hasFolding(curwin->w_topline, NULL, &curwin->w_topline)
|
||||||
|
&& curwin->w_topline == curbuf->b_ml.ml_line_count) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
curwin->w_topline++;
|
curwin->w_topline++;
|
||||||
curwin->w_topfill = win_get_fill(curwin, curwin->w_topline);
|
curwin->w_topfill = win_get_fill(curwin, curwin->w_topline);
|
||||||
}
|
}
|
||||||
@@ -1393,8 +1392,7 @@ bool mouse_comp_pos(win_T *win, int *rowp, int *colp, linenr_T *lnump)
|
|||||||
|
|
||||||
while (row > 0) {
|
while (row > 0) {
|
||||||
// Don't include filler lines in "count"
|
// Don't include filler lines in "count"
|
||||||
if (win_may_fill(win)
|
if (win_may_fill(win)) {
|
||||||
&& !hasFoldingWin(win, lnum, NULL, NULL, true, NULL)) {
|
|
||||||
if (lnum == win->w_topline) {
|
if (lnum == win->w_topline) {
|
||||||
row -= win->w_topfill;
|
row -= win->w_topfill;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -132,8 +132,7 @@ int plines_win_nofold(win_T *wp, linenr_T lnum)
|
|||||||
/// used from the start of the line to the given column number.
|
/// used from the start of the line to the given column number.
|
||||||
int plines_win_col(win_T *wp, linenr_T lnum, long column)
|
int plines_win_col(win_T *wp, linenr_T lnum, long column)
|
||||||
{
|
{
|
||||||
// Check for filler lines above this buffer line. When folded the result
|
// Check for filler lines above this buffer line.
|
||||||
// is one line anyway.
|
|
||||||
int lines = win_get_fill(wp, lnum);
|
int lines = win_get_fill(wp, lnum);
|
||||||
|
|
||||||
if (!wp->w_p_wrap) {
|
if (!wp->w_p_wrap) {
|
||||||
|
@@ -42,6 +42,7 @@ describe("folded lines", function()
|
|||||||
[10] = {background = Screen.colors.LightGrey, underline = true},
|
[10] = {background = Screen.colors.LightGrey, underline = true},
|
||||||
[11] = {bold=true},
|
[11] = {bold=true},
|
||||||
[12] = {background = Screen.colors.Grey90},
|
[12] = {background = Screen.colors.Grey90},
|
||||||
|
[16] = {background = Screen.colors.LightGrey},
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -2010,6 +2011,17 @@ describe("folded lines", function()
|
|||||||
]])
|
]])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
meths.input_mouse('left', 'press', '', multigrid and 2 or 0, 4, 0)
|
||||||
|
eq({
|
||||||
|
column = 1,
|
||||||
|
line = 3,
|
||||||
|
screencol = 1,
|
||||||
|
screenrow = 5,
|
||||||
|
wincol = 1,
|
||||||
|
winid = 1000,
|
||||||
|
winrow = 5,
|
||||||
|
}, funcs.getmousepos())
|
||||||
|
|
||||||
meths.buf_set_extmark(0, ns, 1, 0, { virt_lines = {{{"more virt_line below line 2", ""}}} })
|
meths.buf_set_extmark(0, ns, 1, 0, { virt_lines = {{{"more virt_line below line 2", ""}}} })
|
||||||
feed('G<C-E>')
|
feed('G<C-E>')
|
||||||
if multigrid then
|
if multigrid then
|
||||||
@@ -2226,6 +2238,150 @@ describe("folded lines", function()
|
|||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feed('3<C-Y>')
|
||||||
|
if multigrid then
|
||||||
|
screen:expect([[
|
||||||
|
## grid 1
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[3:---------------------------------------------]|
|
||||||
|
## grid 2
|
||||||
|
virt_line below line 2 |
|
||||||
|
more virt_line below line 2 |
|
||||||
|
{5:+-- 2 lines: line 3·························}|
|
||||||
|
^line 5 |
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
## grid 3
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
else
|
||||||
|
screen:expect([[
|
||||||
|
virt_line below line 2 |
|
||||||
|
more virt_line below line 2 |
|
||||||
|
{5:+-- 2 lines: line 3·························}|
|
||||||
|
^line 5 |
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
end
|
||||||
|
|
||||||
|
meths.input_mouse('left', 'press', '3', multigrid and 2 or 0, 3, 0)
|
||||||
|
if multigrid then
|
||||||
|
screen:expect([[
|
||||||
|
## grid 1
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[3:---------------------------------------------]|
|
||||||
|
## grid 2
|
||||||
|
virt_line below line 2 |
|
||||||
|
more virt_line below line 2 |
|
||||||
|
{5:+-- 2 lines: line 3·························}|
|
||||||
|
^l{16:ine 5} |
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
## grid 3
|
||||||
|
{11:-- VISUAL LINE --} |
|
||||||
|
]])
|
||||||
|
else
|
||||||
|
screen:expect([[
|
||||||
|
virt_line below line 2 |
|
||||||
|
more virt_line below line 2 |
|
||||||
|
{5:+-- 2 lines: line 3·························}|
|
||||||
|
^l{16:ine 5} |
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{11:-- VISUAL LINE --} |
|
||||||
|
]])
|
||||||
|
end
|
||||||
|
|
||||||
|
meths.input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 0)
|
||||||
|
if multigrid then
|
||||||
|
screen:expect([[
|
||||||
|
## grid 1
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[3:---------------------------------------------]|
|
||||||
|
## grid 2
|
||||||
|
more virt_line below line 2 |
|
||||||
|
{5:+-- 2 lines: line 3·························}|
|
||||||
|
^l{16:ine 5} |
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
## grid 3
|
||||||
|
{11:-- VISUAL LINE --} |
|
||||||
|
]])
|
||||||
|
else
|
||||||
|
screen:expect([[
|
||||||
|
more virt_line below line 2 |
|
||||||
|
{5:+-- 2 lines: line 3·························}|
|
||||||
|
^l{16:ine 5} |
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{11:-- VISUAL LINE --} |
|
||||||
|
]])
|
||||||
|
end
|
||||||
|
|
||||||
|
meths.input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 5)
|
||||||
|
if multigrid then
|
||||||
|
screen:expect([[
|
||||||
|
## grid 1
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[2:---------------------------------------------]|
|
||||||
|
[3:---------------------------------------------]|
|
||||||
|
## grid 2
|
||||||
|
{5:+-- 2 lines: line 3·························}|
|
||||||
|
{16:line }^5 |
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
## grid 3
|
||||||
|
{11:-- VISUAL LINE --} |
|
||||||
|
]])
|
||||||
|
else
|
||||||
|
screen:expect([[
|
||||||
|
{5:+-- 2 lines: line 3·························}|
|
||||||
|
{16:line }^5 |
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{11:-- VISUAL LINE --} |
|
||||||
|
]])
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user