llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Raphael Isemann (Teemperor) <details> <summary>Changes</summary> This patch shows a description next to each settings completion. --- Full diff: https://github.com/llvm/llvm-project/pull/206044.diff 2 Files Affected: - (modified) lldb/source/Commands/CommandCompletions.cpp (+18-3) - (modified) lldb/test/API/functionalities/completion/TestCompletion.py (+12) ``````````diff diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index 3f652e2512182..647b04d7ecf40 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -21,6 +21,7 @@ #include "lldb/Interpreter/CommandObject.h" #include "lldb/Interpreter/CommandObjectMultiword.h" #include "lldb/Interpreter/OptionValueProperties.h" +#include "lldb/Interpreter/Property.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Variable.h" #include "lldb/Target/Language.h" @@ -592,8 +593,9 @@ void CommandCompletions::Symbols(CommandInterpreter &interpreter, void CommandCompletions::SettingsNames(CommandInterpreter &interpreter, CompletionRequest &request, SearchFilter *searcher) { - // Cache the full setting name list + // Cache the full setting name/description list. static StringList g_property_names; + static StringList g_property_descriptions; if (g_property_names.GetSize() == 0) { // Generate the full setting name list on demand lldb::OptionValuePropertiesSP properties_sp( @@ -603,11 +605,24 @@ void CommandCompletions::SettingsNames(CommandInterpreter &interpreter, properties_sp->DumpValue(nullptr, strm, OptionValue::eDumpOptionName); const std::string &str = std::string(strm.GetString()); g_property_names.SplitIntoLines(str.c_str(), str.size()); + + // Look up the description for each setting name so it can be displayed + // alongside the completion. + for (const std::string &name : g_property_names) { + std::string description; + if (const Property *property = + properties_sp->GetPropertyAtPath(nullptr, name)) + description = property->GetDescription().str(); + g_property_descriptions.AppendString(description); + } } } - for (const std::string &s : g_property_names) - request.TryCompleteCurrentArg(s); + assert(g_property_names.GetSize() == g_property_descriptions.GetSize() && + "Not all properties got descriptions?"); + for (size_t i = 0; i < g_property_names.GetSize(); ++i) + request.TryCompleteCurrentArg(g_property_names[i], + g_property_descriptions[i]); } void CommandCompletions::PlatformPluginNames(CommandInterpreter &interpreter, diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py index 04253b15c041d..aecfce2c58a27 100644 --- a/lldb/test/API/functionalities/completion/TestCompletion.py +++ b/lldb/test/API/functionalities/completion/TestCompletion.py @@ -375,6 +375,18 @@ def test_settings_set_th(self): """Test that 'settings set thread-f' completes to 'settings set thread-format'.""" self.complete_from_to("settings set thread-f", "settings set thread-format") + def test_settings_set_shows_description(self): + """Test that 'settings set' completions also offer the setting description.""" + self.check_completion_with_desc( + "settings set term-w", + [ + [ + "term-width", + "The maximum number of columns to use for displaying text.", + ] + ], + ) + def test_settings_s_dash(self): """Test that 'settings set --g' completes to 'settings set --global'.""" self.complete_from_to("settings set --g", "settings set --global") `````````` </details> https://github.com/llvm/llvm-project/pull/206044 _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
