Way to reproduce:
This bug was introduced in d30826d02dd914e5a9923df074539bb35d2c7e48.
runtime error: slice bounds out of range
...
/usr/local/go/src/runtime/panic.go:491 +0x283
github.com/elves/elvish/edit.(*Editor).insertDefault(0xc42015a380)
/go/src/github.com/elves/elvish/edit/insert.go:351 +0x5d9
I've added some debug info when this case happens (before line 351):
lower bound is negative: len(ed.buffer):1, literalInserts: 3, dot: 1
I can confirm this behavior.
@zzamboni, checking out parent commit cbf6e7c67d9ca14b9cadc24a72852438ac8ff601 helps btw.
I've noticed that pressing Enter after the Ctrl-C seems to act as a workaround. It also explains why I had noticed what seemed to be an intermittent bug...it wasn't intermittent, I apparently just press Enter a lot.
It seems that not only with Enter, but with every key(combination) that don't insert characters to the readline: Escape, Backspace, Delete, Alt-[any], Ctrl-[any]
Thanks for reporting! I decoupled most of the house-keeping from the editor proper, and now the insert mode is not resetting some of its states correctly.
Thanks for fixing this!
Most helpful comment
Thanks for reporting! I decoupled most of the house-keeping from the editor proper, and now the insert mode is not resetting some of its states correctly.