[Lldb-commits] [PATCH] D12531: Fix tab completion for command arguments containing spaces

Tamas Berghammer via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 1 08:13:44 PDT 2015


tberghammer updated this revision to Diff 33692.
tberghammer added a comment.

Address review comment (the function already exists in Args)


http://reviews.llvm.org/D12531

Files:
  source/Interpreter/Options.cpp
  test/functionalities/completion/Makefile
  test/functionalities/completion/TestCompletion.py
  test/functionalities/completion/main.cpp

Index: test/functionalities/completion/main.cpp
===================================================================
--- /dev/null
+++ test/functionalities/completion/main.cpp
@@ -0,0 +1,14 @@
+class Foo
+{
+public:
+    int Bar(int x, int y)
+    {
+        return x + y;
+    }
+};
+
+int main()
+{
+    Foo f;
+    f.Bar(1, 2);
+}
Index: test/functionalities/completion/TestCompletion.py
===================================================================
--- test/functionalities/completion/TestCompletion.py
+++ test/functionalities/completion/TestCompletion.py
@@ -219,6 +219,23 @@
         """Test that 'target va' completes to 'target variable '."""
         self.complete_from_to('target va', 'target variable ')
 
+    @skipUnlessDarwin
+    @dsym_test
+    def test_symbol_name_dsym(self):
+        self.buildDsym()
+        self.complete_from_to('''file a.out
+                                 breakpoint set -n Fo''',
+                              'breakpoint set -n Foo::Bar(int,\\ int)',
+                              turn_off_re_match=True)
+
+    @dwarf_test
+    def test_symbol_name_dwarf(self):
+        self.buildDwarf()
+        self.complete_from_to('''file a.out
+                                 breakpoint set -n Fo''',
+                              'breakpoint set -n Foo::Bar(int,\\ int)',
+                              turn_off_re_match=True)
+
     def complete_from_to(self, str_input, patterns, turn_off_re_match=False):
         """Test that the completion mechanism completes str_input to patterns,
         where patterns could be a pattern-string or a list of pattern-strings"""
Index: test/functionalities/completion/Makefile
===================================================================
--- /dev/null
+++ test/functionalities/completion/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
Index: source/Interpreter/Options.cpp
===================================================================
--- source/Interpreter/Options.cpp
+++ source/Interpreter/Options.cpp
@@ -975,15 +975,24 @@
         }
     }
 
-    return CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
-                                                                completion_mask,
-                                                                input.GetArgumentAtIndex (opt_arg_pos),
-                                                                match_start_point,
-                                                                max_return_elements,
-                                                                filter_ap.get(),
-                                                                word_complete,
-                                                                matches);
-    
+    bool ret = CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
+                                                                    completion_mask,
+                                                                    input.GetArgumentAtIndex (opt_arg_pos),
+                                                                    match_start_point,
+                                                                    max_return_elements,
+                                                                    filter_ap.get(),
+                                                                    word_complete,
+                                                                    matches);
+
+    // Escape spaces and backslashes in the matches list as the arguments shouldn't contain any of
+    // these characters without escaping.
+    for (size_t i = 0; i < matches.GetSize(); ++i)
+    {
+        std::string s;
+        Args::GetShellSafeArgument(matches[i].c_str(), s);
+        matches[i] = s;
+    }
+    return ret;
 }
 
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12531.33692.patch
Type: text/x-patch
Size: 3839 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150901/eb595c98/attachment-0001.bin>


More information about the lldb-commits mailing list