Skip to content

Commit

Permalink
kdb: Tweak escape handling for vi users
Browse files Browse the repository at this point in the history
Currently if sequences such as "\ehelp\r" are delivered to the console then
the h gets eaten by the escape handling code. Since pressing escape
becomes something of a nervous twitch for vi users (and that escape doesn't
have much effect at a shell prompt) it is more helpful to emit the 'h' than
the '\e'.

We don't simply choose to emit the final character for all escape sequences
since that will do odd things for unsupported escape sequences (in
other words we retain the existing behaviour once we see '\e[').

Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/r/20191025073328.643-6-daniel.thompson@linaro.org
  • Loading branch information
daniel-thompson committed Oct 28, 2019
1 parent cdca8d8 commit c58ff64
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/debug/kdb/kdb_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ char kdb_getchar(void)

*pbuf++ = key;
key = kdb_handle_escape(buf, pbuf - buf);
if (key < 0) /* no escape sequence; return first character */
return buf[0];
if (key < 0) /* no escape sequence; return best character */
return buf[pbuf - buf == 2 ? 1 : 0];
if (key > 0)
return key;
}
Expand Down

0 comments on commit c58ff64

Please sign in to comment.