Skip to content

Commit c58ff64

Browse files
author
Daniel Thompson
committed
kdb: Tweak escape handling for vi users
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 <[email protected]> Reviewed-by: Douglas Anderson <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent cdca8d8 commit c58ff64

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/debug/kdb/kdb_io.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ char kdb_getchar(void)
163163

164164
*pbuf++ = key;
165165
key = kdb_handle_escape(buf, pbuf - buf);
166-
if (key < 0) /* no escape sequence; return first character */
167-
return buf[0];
166+
if (key < 0) /* no escape sequence; return best character */
167+
return buf[pbuf - buf == 2 ? 1 : 0];
168168
if (key > 0)
169169
return key;
170170
}

0 commit comments

Comments
 (0)