From 035460d315c71ac78f6741fca6f87ac65c54fb42 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 25 May 2026 09:05:44 +0300 Subject: fix: exclude 'help' from help topic completions 'help ' was suggesting 'help help'. Skip 'help' itself in GetCompletionTopics so tab completion offers actual topics. --- internal/repl/help.go | 5 ++++- internal/repl/help_test.go | 11 +++++++++-- 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) { -- cgit v1.2.3