From f7109ab46b3313ff1ca9f55990c8d926a3c7081d Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Tue, 29 Jan 2013 14:59:47 +0300 Subject: [PATCH] Fix for input completions with spaces in names. Signed-off-by: Slava Zanko --- lib/widget/input_complete.c | 5 ++++- tests/lib/widget/complete_engine.c | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/widget/input_complete.c b/lib/widget/input_complete.c index 4b1b54c3e..0bceaa938 100644 --- a/lib/widget/input_complete.c +++ b/lib/widget/input_complete.c @@ -1382,6 +1382,9 @@ void complete_engine_fill_completions (WInput * in) { char *s; + const char *word_separators; + + word_separators = (in->completion_flags & INPUT_COMPLETE_SHELL_ESC) ? " \t;|<>" : "\t;|<>"; end = str_offset_to_pos (in->buffer, in->point); @@ -1398,7 +1401,7 @@ complete_engine_fill_completions (WInput * in) for (; s >= in->buffer; str_prev_char (&s)) { start = s - in->buffer; - if (strchr (" \t;|<>", *s) != NULL) + if (strchr (word_separators, *s) != NULL && !strutils_is_char_escaped (in->buffer, s)) break; } diff --git a/tests/lib/widget/complete_engine.c b/tests/lib/widget/complete_engine.c index d811d247a..94352b217 100644 --- a/tests/lib/widget/complete_engine.c +++ b/tests/lib/widget/complete_engine.c @@ -123,10 +123,31 @@ static const struct test_complete_engine_fill_completions_ds "some string", 7, INPUT_COMPLETE_NONE, + 0, + 7 + }, + { + "some string", + 7, + INPUT_COMPLETE_SHELL_ESC, 5, 7 }, { + "some\\ string111", + 9, + INPUT_COMPLETE_SHELL_ESC, + 0, + 9 + }, + { + "some\\\tstring111", + 9, + INPUT_COMPLETE_SHELL_ESC, + 0, + 9 + }, + { "some\tstring", 7, INPUT_COMPLETE_NONE, -- 2.11.4.GIT