neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit b3096b5860ca4c9a9b9c15a96026c1da080ac8de
parent 4afbc25432820be65fc304717b2e8f450c92ff62
Author: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Date:   Sun, 15 Feb 2026 01:27:25 +0000

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.

Diffstat:
Msrc/nvim/edit.c | 4++++
Mtest/functional/legacy/prompt_buffer_spec.lua | 7+++++++
2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/src/nvim/edit.c b/src/nvim/edit.c @@ -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); diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua @@ -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()