Fix latent bug in custom word point completion handling
authorPedro Alves <palves@redhat.com>
Wed, 12 Jun 2019 23:06:52 +0000 (00:06 +0100)
committerPedro Alves <palves@redhat.com>
Wed, 12 Jun 2019 23:06:52 +0000 (00:06 +0100)
Without this fix, if we switch the "print" completer to custom word
point handling, we regress gdb.base/completion.exp like this:

 (gdb) p "break1.c FAIL: gdb.base/completion.exp: complete 'p "break1' (timeout)

The problem is that completing an expression that starts with double
quotes, and resolves to a filename, like this:

 (gdb) p "break1[TAB]

would change from this, with current master:

 (gdb) p "break1.c"|
         ^^^^^^^^^^|
                   \- cursor here

to this:

 (gdb) p "break1.c |
         ^^^^^^^^^^|
                   \- quote replaced by space

The issue is that completer.c:advance_to_completion_word misses
telling the completion tracker to emulate readline's handling of
completing a string when rl_find_completion_word returns a delimiter.

This commit fixes the latent bug.

gdb/ChangeLog:
2019-06-13  Pedro Alves  <palves@redhat.com>

* completer.c (advance_to_completion_word): Handle delimiters.

gdb/ChangeLog
gdb/completer.c

index f282e122540747d0ef25835b29c7e78d1cf778a8..19b2a7dc76c89d20bea5ec79a619b1530b51aba6 100644 (file)
@@ -1,3 +1,7 @@
+2019-06-13  Pedro Alves  <palves@redhat.com>
+
+       * completer.c (advance_to_completion_word): Handle delimiters.
+
 2019-06-11  Bernhard Heckel  <bernhard.heckel@intel.com>
 
        * dwarf2read.c (add_partial_symbol): Skip nameless modules.
index d4773f2a77b536e145b5c65e74a11b1ebaf6ff46..03d0d0e5dbd39d6ec340402e46800a906fd2f9f4 100644 (file)
@@ -365,11 +365,18 @@ advance_to_expression_complete_word_point (completion_tracker &tracker,
   info.quote_characters = gdb_completer_quote_characters;
   info.basic_quote_characters = rl_basic_quote_characters;
 
+  int delimiter;
   const char *start
-    = gdb_rl_find_completion_word (&info, NULL, NULL, text);
+    = gdb_rl_find_completion_word (&info, NULL, &delimiter, text);
 
   tracker.advance_custom_word_point_by (start - text);
 
+  if (delimiter)
+    {
+      tracker.set_quote_char (delimiter);
+      tracker.set_suppress_append_ws (true);
+    }
+
   return start;
 }