Vim mode: double-Esc undo leaves normal mode, so '.' duplicates content on the very first keystroke

Status Open
Maintainer reply None cached
Activity 0 comments · opened Jul 22, 2026

Description

In vim mode, using double-Esc to undo a message leaves the input in normal mode instead of insert mode. If the next keystroke is . (repeat last change), it duplicates the content — even though no edit has actually been made since the undo.

/rewind avoids that specific issue because it automatically enters insert mode after rewinding. However, if you then press Esc to go from insert mode back to normal mode, . still duplicates the content — so the underlying problem is broader than just double-Esc: a stale "last change" survives both undo paths and gets replayed by . even when no edit happened since.

Steps to reproduce

Case 1 (double-Esc undo):

  1. Enable vim mode.
  2. Type a message.
  3. Press Esc twice to undo the message.
  4. Press . as the very first keystroke after the undo.

Case 2 (/rewind then Esc):

  1. Enable vim mode.
  2. Type a message.
  3. Run /rewind.
  4. Press Esc to go from insert mode to normal mode.
  5. Press . as the first keystroke since.

Expected behavior

In both cases, . right after an undo/rewind (with no intervening edit) should be a no-op, since there's no new "last change" to repeat.

Actual behavior

In both cases, . duplicates content — it's replaying a change from before the undo/rewind rather than being a no-op.

View original on GitHub ↗