Fix for input completions with spaces in names.
authorSlava Zanko <slavazanko@gmail.com>
Tue, 29 Jan 2013 11:59:47 +0000 (29 14:59 +0300)
committerSlava Zanko <slavazanko@gmail.com>
Mon, 4 Feb 2013 12:48:21 +0000 (4 15:48 +0300)
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
lib/widget/input_complete.c
tests/lib/widget/complete_engine.c

index 4b1b54c..0bceaa9 100644 (file)
@@ -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;
     }
 
index d811d24..94352b2 100644 (file)
@@ -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,