mirror of
https://github.com/neovim/neovim.git
synced 2026-03-30 20:32:08 +00:00
fix(prompt): ml_get error with invalid ': lnum
Problem: internal error E315 in init_prompt if ': has an invalid line number. Solution: clamp the line number.
This commit is contained in:
@@ -1593,6 +1593,10 @@ static void init_prompt(int cmdchar_todo)
|
||||
char *prompt = prompt_text();
|
||||
int prompt_len = (int)strlen(prompt);
|
||||
|
||||
// In case the mark is set to a nonexistent line.
|
||||
curbuf->b_prompt_start.mark.lnum = MIN(curbuf->b_prompt_start.mark.lnum,
|
||||
curbuf->b_ml.ml_line_count);
|
||||
|
||||
curwin->w_cursor.lnum = MAX(curwin->w_cursor.lnum, curbuf->b_prompt_start.mark.lnum);
|
||||
char *text = ml_get(curbuf->b_prompt_start.mark.lnum);
|
||||
colnr_T text_len = ml_get_len(curbuf->b_prompt_start.mark.lnum);
|
||||
|
||||
@@ -671,6 +671,13 @@ describe('prompt buffer', function()
|
||||
-- No crash from invalid col.
|
||||
eq(true, api.nvim_buf_set_mark(0, ':', fn('line', '.'), 999, {}))
|
||||
eq({ 12, 6 }, api.nvim_buf_get_mark(0, ':'))
|
||||
|
||||
-- No ml_get error from invalid lnum.
|
||||
command('set messagesopt+=wait:0 messagesopt-=hit-enter')
|
||||
fn('setpos', "':", { 0, 999, 7, 0 })
|
||||
eq('', api.nvim_get_vvar('errmsg'))
|
||||
command('set messagesopt&')
|
||||
eq({ 12, 6 }, api.nvim_buf_get_mark(0, ':'))
|
||||
end)
|
||||
|
||||
describe('prompt_getinput', function()
|
||||
|
||||
Reference in New Issue
Block a user