commit 2f8fb4f28ab92d62e07d1d64a6dd89e0b6eb7253
parent 0977f70f4dd3d14175697d5e6568d4019019506f
Author: luukvbaal <luukvbaal@gmail.com>
Date: Sun, 13 Apr 2025 23:30:24 +0200
fix(mouse): mouseclick after conceal_lines is miscalculated #33451
Problem: Computed buffer line for mouse position does not take into
account concealed lines on the reached row.
Solution: Adjust for concealed lines at the end of the loop computing
the buffer position.
Diffstat:
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c
@@ -9,6 +9,7 @@
#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
+#include "nvim/decoration.h"
#include "nvim/drawscreen.h"
#include "nvim/edit.h"
#include "nvim/eval.h"
@@ -1659,6 +1660,12 @@ bool mouse_comp_pos(win_T *win, int *rowp, int *colp, linenr_T *lnump)
lnum++;
}
+ // Mouse row reached, adjust lnum for concealed lines.
+ while (decor_conceal_line(win, lnum - 1, false)) {
+ lnum++;
+ hasFolding(win, lnum, NULL, &lnum);
+ }
+
if (!retval) {
// Compute the column without wrapping.
int off = win_col_off(win) - win_col_off2(win);
diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua
@@ -2082,4 +2082,12 @@ describe('ui/mouse/input', function()
feed('<Down><Down><CR>')
eq('bar', api.nvim_get_var('menustr'))
end)
+
+ it('below a concealed line #33450', function()
+ api.nvim_set_option_value('conceallevel', 2, {})
+ api.nvim_buf_set_extmark(0, api.nvim_create_namespace(''), 1, 0, { conceal_lines = '' })
+ api.nvim_input_mouse('right', 'press', '', 0, 1, 0)
+ api.nvim_input_mouse('right', 'release', '', 0, 1, 0)
+ eq(3, fn.line('.'))
+ end)
end)