diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py @@ -23,7 +23,7 @@ self.assertFalse(not_expected_item in actual_list) @skipIfWindows - @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots + #@skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots def test_completions(self): """ Tests the completion request at different breakpoints @@ -113,3 +113,43 @@ } ], ) + + self.verify_completions( + self.vscode.get_completions("foo1.v"), + [ + { + "text": "var1", + "label": "foo1.var1 -- int" + } + ] + ) + + self.verify_completions( + self.vscode.get_completions("foo1.my_bar_object.v"), + [ + { + "text": "var1", + "label": "foo1.my_bar_object.var1 -- int" + } + ] + ) + + self.verify_completions( + self.vscode.get_completions("foo1.var1 + foo1.v"), + [ + { + "text": "var1", + "label": "foo1.var1 -- int" + } + ] + ) + + self.verify_completions( + self.vscode.get_completions("foo1.var1 + v"), + [ + { + "text": "var1", + "label": "var1 -- int &" + } + ] + ) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/main.cpp b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/main.cpp --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/main.cpp +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/main.cpp @@ -1,6 +1,17 @@ #include #include +struct bar { + int var1; +}; + +struct foo { + int var1; + bar* my_bar_pointer; + bar my_bar_object; + foo* next_foo; +}; + int fun(std::vector var) { return var.size(); // breakpoint 1 } @@ -12,5 +23,8 @@ std::string str2 = "b"; std::vector vec; fun(vec); + bar bar1 = {2}; + bar* bar2 = &bar1; + foo foo1 = {3,&bar1, bar1, NULL}; return 0; // breakpoint 2 } diff --git a/lldb/tools/lldb-vscode/lldb-vscode.cpp b/lldb/tools/lldb-vscode/lldb-vscode.cpp --- a/lldb/tools/lldb-vscode/lldb-vscode.cpp +++ b/lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -951,9 +951,27 @@ for (size_t i = 0; i < count; i++) { std::string match = matches.GetStringAtIndex(i); std::string description = descriptions.GetStringAtIndex(i); - + llvm::json::Object item; - EmplaceSafeString(item, "text", match); + + std::vector commit_points = {".", "->"}; + int max_breakpoint_position = -1; + int commit_points_index = -1; + for (uint32_t breakpoint_index = 0; breakpoint_index < commit_points.size(); breakpoint_index++) { + int breakpoint_position = match.rfind(commit_points[breakpoint_index]); + if (max_breakpoint_position < breakpoint_position){ + commit_points_index = breakpoint_index; + max_breakpoint_position = breakpoint_position; + } + } + + if (max_breakpoint_position != -1) { + std::string cut_match = match.substr(max_breakpoint_position + commit_points[commit_points_index].length(), match.length() - max_breakpoint_position); + EmplaceSafeString(item, "text", cut_match); + } else { + EmplaceSafeString(item, "text", match); + } + if (description.empty()) EmplaceSafeString(item, "label", match); else