summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-25 09:05:44 +0300
committerPaul Buetow <paul@buetow.org>2026-05-25 09:05:44 +0300
commit035460d315c71ac78f6741fca6f87ac65c54fb42 (patch)
treee28564fcee107dbc0f120501831c345303a9d440
parent7b3ff83f749724d452215fe135765b7e6aba92f5 (diff)
fix: exclude 'help' from help topic completions
'help <TAB>' was suggesting 'help help'. Skip 'help' itself in GetCompletionTopics so tab completion offers actual topics.
-rw-r--r--internal/repl/help.go5
-rw-r--r--internal/repl/help_test.go11
2 files changed, 13 insertions, 3 deletions
diff --git a/internal/repl/help.go b/internal/repl/help.go
index 5192085..1aaec09 100644
--- a/internal/repl/help.go
+++ b/internal/repl/help.go
@@ -537,8 +537,11 @@ func GetCompletionTopics() []string {
// Add "categories" as a special topic
topics = append(topics, "categories")
- // Add all operator names
+ // Add all operator names (skip "help" itself — no need to complete help help)
for op, t := range helpByTopic {
+ if op == "help" {
+ continue
+ }
topics = append(topics, op)
seen[op] = true
// Add aliases
diff --git a/internal/repl/help_test.go b/internal/repl/help_test.go
index ca77462..9813ebb 100644
--- a/internal/repl/help_test.go
+++ b/internal/repl/help_test.go
@@ -134,8 +134,8 @@ func TestGetCompletionTopicsIncludesAliases(t *testing.T) {
expectedAliases := []string{"exit", "calc", "gt", "lt", "categories"}
for _, expected := range expectedAliases {
found := false
- for _, t := range topics {
- if t == expected {
+ for _, topic := range topics {
+ if topic == expected {
found = true
break
}
@@ -144,6 +144,13 @@ func TestGetCompletionTopicsIncludesAliases(t *testing.T) {
t.Errorf("GetCompletionTopics() missing alias/topic %q", expected)
}
}
+
+ // "help" itself should NOT be in completion topics
+ for _, topic := range topics {
+ if topic == "help" {
+ t.Error("GetCompletionTopics() should not include 'help' itself")
+ }
+ }
}
func TestGetCompletionTopicsIsSorted(t *testing.T) {