summaryrefslogtreecommitdiffstats
path: root/linenoise
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-09-30 20:30:31 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-09-30 20:30:31 -0700
commitb7dadaf6772a3c641c0b232bea5164365d4ecc2b (patch)
treebc26aab54fe549ed4300d1ee0c54eae8757e69b7 /linenoise
parent8f86d0ed3723f7f3e47efa9ae9a480d7f98b4783 (diff)
downloadtxr-b7dadaf6772a3c641c0b232bea5164365d4ecc2b.tar.gz
txr-b7dadaf6772a3c641c0b232bea5164365d4ecc2b.tar.bz2
txr-b7dadaf6772a3c641c0b232bea5164365d4ecc2b.zip
linenoise: bugfix: handle ESC in extended command.
If the user types Ctrl-X and then an arrow key, we don't want garbage. We let an ESC received in Ctrl-X extended command mode to be processed normally and cancel that mode. * linenoise.c (edit): Bypass the extended command switch if the character is ESC. Then down below in the ESC case of the regular command switch, clear extended mode.
Diffstat (limited to 'linenoise')
-rw-r--r--linenoise/linenoise.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c
index 225fcb8d..7e78adf9 100644
--- a/linenoise/linenoise.c
+++ b/linenoise/linenoise.c
@@ -1775,7 +1775,7 @@ static int edit(lino_t *l, const char *prompt)
continue;
}
- if (extended && c != TAB) {
+ if (extended && c != TAB && c != ESC) {
switch (c) {
case CTL('E'):
extended = 0;
@@ -1983,6 +1983,7 @@ static int edit(lino_t *l, const char *prompt)
edit_history_next(l, LINENOISE_HISTORY_NEXT);
break;
case ESC:
+ extended = 0;
/* Read the next two bytes representing the escape sequence.
* Use two calls to handle slow terminals returning the two
* chars at different times. */