Download raw body.
ksh vi edit mode history navigation fix
Hi all,
I've been having this issue for ages, and I'm not even sure anyone ever noticed, or maybe they did and it was just so insignificant that they never bothered to dig into it.. Anyway, TL;DR:
--- a/bin/ksh/vi.c
+++ b/bin/ksh/vi.c
@@ -297,6 +297,7 @@ vi_hook(int ch)
state = nextstate(ch);
if (state == VSEARCH) {
save_cbuf();
+ srchlen = 0;
es->cursor = 0;
es->linelen = 0;
if (ch == '/') {
I've also attached the diff because I'm positive the tabs get messed up inline.
The issue itself is a bit convoluted:
So I'm accessing the command line history - in vi edit mode - by pressing ESC then '/', then start typing e.g.: "pac" (as in start of pacman).
I press CTRL+c, I'm immediately back in my shell, no problem, I can execute commands, it works fine.
However, if I press ESC then '/' again, and start typing "pac" again and press enter, then the terminal bell rings and the editor fills in the most recent command from history, and the search fails.
The reason I even know about this is that I don't delete my typos when searching through the history, I just hit CTRL+c and start over... I'm lazy like that.
The diff is courtesy of Codex; I'm not even gonna get into how long I've been digging in ksh's trenches before I finally gave up.
Daniel
diff --git a/bin/ksh/vi.c b/bin/ksh/vi.c
index 42e03b0e3f6..1e3c36834d3 100644
--- a/bin/ksh/vi.c
+++ b/bin/ksh/vi.c
@@ -297,6 +297,7 @@ vi_hook(int ch)
state = nextstate(ch);
if (state == VSEARCH) {
save_cbuf();
+ srchlen = 0;
es->cursor = 0;
es->linelen = 0;
if (ch == '/') {
ksh vi edit mode history navigation fix