kurku

Readline: vi mode mark & arrows hazards

What is broken?

By default in normal mode of vi we have these bindings:

vi-delete-to can be found on "D", "d".
vi-change-to can be found on "C", "c".

rl_vi_set_mark calls _rl_vi_set_mark

and is defined as

/* Functions to save and restore marks. */
static int
_rl_vi_set_mark (void)
{
  int ch;

  RL_SETSTATE(RL_STATE_MOREINPUT);
  ch = rl_read_key ();
  RL_UNSETSTATE(RL_STATE_MOREINPUT);

  if (ch < 0 || ch < 'a' || ch > 'z')    /* make test against 0 explicit */
    {
      rl_ding ();
      return 1;
    }
  ch -= 'a';
  vi_mark_chars[ch] = rl_point;
  return 0;
}

When the user presses m with LeftArrow \e[C right after. Readline kills or deletes the line to the end.

Status

fixed by me, merged upstream

https://lists.gnu.org/archive/html/bug-readline/2026-07/msg00003.html https://lists.gnu.org/archive/html/bug-readline/2026-07/msg00004.html https://lists.gnu.org/archive/html/bug-readline/2026-08/msg00003.html