From f14eb9199f4e1aee49594e590c08996244bb77b3 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 28 Sep 2025 21:56:32 +0300 Subject: Add slash toggle for completions --- internal/lsp/chat_commands_test.go | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'internal/lsp/chat_commands_test.go') diff --git a/internal/lsp/chat_commands_test.go b/internal/lsp/chat_commands_test.go index 87cc1b4..0e31c7b 100644 --- a/internal/lsp/chat_commands_test.go +++ b/internal/lsp/chat_commands_test.go @@ -32,6 +32,9 @@ func TestHandleHelpCommandListsReload(t *testing.T) { if !strings.Contains(res.message, "/reload?>") { t.Fatalf("expected reload command in help output: %q", res.message) } + if !strings.Contains(res.message, "/disable?>") || !strings.Contains(res.message, "/enable?>") { + t.Fatalf("expected completion toggle commands in help output: %q", res.message) + } } func TestHandleReloadCommandReloadsStore(t *testing.T) { @@ -105,6 +108,7 @@ func TestDetectAndHandleChatExecutesSlashCommand(t *testing.T) { s.configStore = store var out bytes.Buffer s.out = &out + s.setCompletionsDisabled(true) // chat commands should remain available when completions are disabled uri := "file:///cmd.go" s.setDocument(uri, "/reload>\n") @@ -119,3 +123,40 @@ func TestDetectAndHandleChatExecutesSlashCommand(t *testing.T) { t.Fatalf("expected reload summary logged, got %q", logBuf.String()) } } + +func TestDisableEnableCommandsToggleCompletions(t *testing.T) { + s := newTestServer() + if s.completionDisabled() { + t.Fatalf("expected completions enabled initially") + } + + if res, ok := s.chatCommandResponse("file:///x", 0, "/disable>"); !ok { + t.Fatalf("expected disable command to be handled") + } else if !strings.Contains(res.message, "disabled") { + t.Fatalf("unexpected disable message: %q", res.message) + } + if !s.completionDisabled() { + t.Fatalf("expected completions disabled after command") + } + + if res, ok := s.chatCommandResponse("file:///x", 0, "/disable>"); !ok { + t.Fatalf("expected repeated disable command to be handled") + } else if !strings.Contains(res.message, "already disabled") { + t.Fatalf("expected already-disabled message, got %q", res.message) + } + + if res, ok := s.chatCommandResponse("file:///x", 0, "/enable>"); !ok { + t.Fatalf("expected enable command to be handled") + } else if !strings.Contains(res.message, "enabled") { + t.Fatalf("unexpected enable message: %q", res.message) + } + if s.completionDisabled() { + t.Fatalf("expected completions enabled after command") + } + + if res, ok := s.chatCommandResponse("file:///x", 0, "/enable>"); !ok { + t.Fatalf("expected repeated enable command to be handled") + } else if !strings.Contains(res.message, "already enabled") { + t.Fatalf("expected already-enabled message, got %q", res.message) + } +} -- cgit v1.2.3