Author: Raphael Isemann
Date: 2026-06-29T13:04:26+01:00
New Revision: 5c158012815d6f5d9ac5ec71a1273773ca5d070b

URL: 
https://github.com/llvm/llvm-project/commit/5c158012815d6f5d9ac5ec71a1273773ca5d070b
DIFF: 
https://github.com/llvm/llvm-project/commit/5c158012815d6f5d9ac5ec71a1273773ca5d070b.diff

LOG: [lldb] Show descriptions for settings (#206044)

This patch shows a description next to each settings completion.

Added: 
    

Modified: 
    lldb/source/Commands/CommandCompletions.cpp
    lldb/test/API/functionalities/completion/TestCompletion.py

Removed: 
    


################################################################################
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")


        
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to