From ab6d9ad521dc6ad96c2a0ea1a2c55702eb5d15c9 Mon Sep 17 00:00:00 2001 From: Chris Pick Date: Thu, 3 Sep 2015 14:20:08 -0400 Subject: [PATCH 1/2] Test vi-mode 't' binding Test 't' binding that contains non-zero arity function (forward-jump) followed by another function (and). This demonstrates the problem in #2357. --- tests/bind.expect | 11 +++++++++++ tests/bind.expect.out | 1 + 2 files changed, 12 insertions(+) diff --git a/tests/bind.expect b/tests/bind.expect index 9df5b37cc..eedc90798 100644 --- a/tests/bind.expect +++ b/tests/bind.expect @@ -37,6 +37,17 @@ expect_prompt -re {\r\nTAXT\r\n} { puts stderr "Couldn't find expected output 'TAXT'" } +# Test 't' binding that contains non-zero arity function (forward-jump) followed +# by another function (and) https://github.com/fish-shell/fish-shell/issues/2357 +send_line "\033ddiecho TEXT\033hhtTrN" +expect_prompt -re {\r\nTENT\r\n} { + puts "t-binding success" +} -nounmatched -re {\r\nfail} { + puts stderr "t-binding fail" +} unmatched { + puts stderr "Couldn't find expected output 'TENT'" +} + # still in insert mode, switch back to regular key bindings send_line "set -g fish_key_bindings fish_default_key_bindings" expect_prompt diff --git a/tests/bind.expect.out b/tests/bind.expect.out index 7f883abdc..5777546db 100644 --- a/tests/bind.expect.out +++ b/tests/bind.expect.out @@ -1,4 +1,5 @@ success success replace success +t-binding success success From 8cc154bc48f730db2303a6bfa91532775fc7ea5b Mon Sep 17 00:00:00 2001 From: Chris Pick Date: Thu, 3 Sep 2015 15:12:56 -0400 Subject: [PATCH 2/2] Fix non-zero arity functions followed by other functions Temporarily skip any queued function code characters when reading the current function's arguments. Fixes #2357. --- src/input.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/input.cpp b/src/input.cpp index 2b556c2a2..6e10074b1 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -42,6 +42,7 @@ #include "output.h" #include #include +#include #define DEFAULT_TERM L"ansi" #define MAX_INPUT_FUNCTION_ARGS 20 @@ -537,10 +538,23 @@ wchar_t input_function_pop_arg() void input_function_push_args(int code) { int arity = input_function_arity(code); + std::deque skipped; + for (int i = 0; i < arity; i++) { - input_function_push_arg(input_common_readch(0)); + wchar_t arg; + + // skip and queue up any function codes + while(((arg = input_common_readch(0)) >= R_MIN) && (arg <= R_MAX)) + { + skipped.push_front(arg); + } + + input_function_push_arg(arg); } + + // push the function codes back into the input stream + std::for_each(skipped.begin(), skipped.end(), input_common_next_ch); } /**