mirror of
https://github.com/neovim/neovim
synced 2025-07-16 09:11:51 +00:00
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:
committed by
github-actions[bot]
parent
e4007551c4
commit
4d87229789
@ -1705,7 +1705,8 @@ static void win_update(win_T *wp)
|
|||||||
// incurring scrolling even though wp->w_topline is still the same.
|
// incurring scrolling even though wp->w_topline is still the same.
|
||||||
// Compare against an adjusted topline instead:
|
// Compare against an adjusted topline instead:
|
||||||
linenr_T topline_conceal = wp->w_topline;
|
linenr_T topline_conceal = wp->w_topline;
|
||||||
while (decor_conceal_line(wp, topline_conceal - 1, false)) {
|
while (topline_conceal < buf->b_ml.ml_line_count
|
||||||
|
&& decor_conceal_line(wp, topline_conceal - 1, false)) {
|
||||||
topline_conceal++;
|
topline_conceal++;
|
||||||
hasFolding(wp, topline_conceal, NULL, &topline_conceal);
|
hasFolding(wp, topline_conceal, NULL, &topline_conceal);
|
||||||
}
|
}
|
||||||
@ -2320,6 +2321,7 @@ static void win_update(win_T *wp)
|
|||||||
|
|
||||||
// Adjust "wl_lastlnum" for concealed lines below the last line in the window.
|
// Adjust "wl_lastlnum" for concealed lines below the last line in the window.
|
||||||
while (row == wp->w_grid.rows
|
while (row == wp->w_grid.rows
|
||||||
|
&& wp->w_lines[idx].wl_lastlnum < buf->b_ml.ml_line_count
|
||||||
&& decor_conceal_line(wp, wp->w_lines[idx].wl_lastlnum, false)) {
|
&& decor_conceal_line(wp, wp->w_lines[idx].wl_lastlnum, false)) {
|
||||||
wp->w_lines[idx].wl_lastlnum++;
|
wp->w_lines[idx].wl_lastlnum++;
|
||||||
hasFolding(wp, wp->w_lines[idx].wl_lastlnum, NULL, &wp->w_lines[idx].wl_lastlnum);
|
hasFolding(wp, wp->w_lines[idx].wl_lastlnum, NULL, &wp->w_lines[idx].wl_lastlnum);
|
||||||
|
@ -1661,7 +1661,8 @@ bool mouse_comp_pos(win_T *win, int *rowp, int *colp, linenr_T *lnump)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mouse row reached, adjust lnum for concealed lines.
|
// Mouse row reached, adjust lnum for concealed lines.
|
||||||
while (decor_conceal_line(win, lnum - 1, false)) {
|
while (lnum < win->w_buffer->b_ml.ml_line_count
|
||||||
|
&& decor_conceal_line(win, lnum - 1, false)) {
|
||||||
lnum++;
|
lnum++;
|
||||||
hasFolding(win, lnum, NULL, &lnum);
|
hasFolding(win, lnum, NULL, &lnum);
|
||||||
}
|
}
|
||||||
|
@ -2086,8 +2086,15 @@ describe('ui/mouse/input', function()
|
|||||||
it('below a concealed line #33450', function()
|
it('below a concealed line #33450', function()
|
||||||
api.nvim_set_option_value('conceallevel', 2, {})
|
api.nvim_set_option_value('conceallevel', 2, {})
|
||||||
api.nvim_buf_set_extmark(0, api.nvim_create_namespace(''), 1, 0, { conceal_lines = '' })
|
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('left', 'press', '', 0, 1, 0)
|
||||||
api.nvim_input_mouse('right', 'release', '', 0, 1, 0)
|
api.nvim_input_mouse('left', 'release', '', 0, 1, 0)
|
||||||
eq(3, fn.line('.'))
|
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)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user