]> git.ipfire.org Git - thirdparty/vim.git/commit
patch 9.2.0408: Insert-mode <Cmd> edits can corrupt undo v9.2.0408
authorJaehwang Jung <tomtomjhj@gmail.com>
Tue, 28 Apr 2026 19:04:39 +0000 (19:04 +0000)
committerChristian Brabandt <cb@256bit.org>
Tue, 28 Apr 2026 19:06:15 +0000 (19:06 +0000)
commite47daed4423182968f64b80c3d7613f0a98a50d4
treea4b7012790847a4d125cf6d6aa3e02ca0ae0a3c5
parent2d43240659868e91e7c371017793091082bfda74
patch 9.2.0408: Insert-mode <Cmd> edits can corrupt undo

Problem:  A <Cmd> command in Insert mode can edit the current buffer,
          e.g., with setline(). That edit appends to the current undo
          block, but Insert mode does not know that the cursor line may
          need to be saved again before the next typed edit. If the next
          typed edit is a <BS> at the start of a line, it can join away
          the line that was changed by the <Cmd> command before Insert
          mode saves that updated line. The newest undo entry can then
          still refer to the joined-away line, so undo sees a range past
          the end of the buffer and fails with E438.
Solution: If a <Cmd> command in Insert mode changes the buffer, set
          ins_need_undo so stop_arrow() refreshes Insstart. This lets
          the next edit properly decide whether a new undo entry is
          needed (Jaehwang Jung)

closes: #20087
AI-assisted: Codex

Signed-off-by: Jaehwang Jung <tomtomjhj@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/edit.c
src/testdir/test_undo.vim
src/version.c