fix(marks): clamp conceal_lines corrected line number #33464

Problem:  Line number corrected for conceal_lines may be set beyond eob
          when the last buffer line is concealed, causing ml_get errors.

Solution: Avoid setting line number beyond eob.
(cherry picked from commit 3341ab0776)
This commit is contained in:
luukvbaal
2025-04-14 13:19:07 +02:00
committed by github-actions[bot]
parent e4007551c4
commit 4d87229789
3 changed files with 14 additions and 4 deletions

View File

@@ -2086,8 +2086,15 @@ describe('ui/mouse/input', function()
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)
api.nvim_input_mouse('left', 'press', '', 0, 1, 0)
api.nvim_input_mouse('left', 'release', '', 0, 1, 0)
eq(3, fn.line('.'))
-- No error when clicking below last line that is concealed.
screen:try_resize(80, 10) -- Prevent hit-enter
api.nvim_set_option_value('cmdheight', 3, {})
local count = api.nvim_buf_line_count(0)
api.nvim_buf_set_extmark(0, 1, count - 1, 0, { conceal_lines = '' })
api.nvim_input_mouse('left', 'press', '', 0, count, 0)
eq('', api.nvim_get_vvar('errmsg'))
end)
end)