diff options
| author | Paul Buetow <paul@buetow.org> | 2025-09-28 21:56:32 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-09-28 21:56:32 +0300 |
| commit | f14eb9199f4e1aee49594e590c08996244bb77b3 (patch) | |
| tree | 6ecc23fda81ddc562bc6431b4e32bf69fd64fceb /internal/lsp/chat_commands_test.go | |
| parent | 6103208e0fd382fb5f8c3e317fa28d888d42cb2b (diff) | |
Add slash toggle for completionsv0.14.0
Diffstat (limited to 'internal/lsp/chat_commands_test.go')
| -rw-r--r-- | internal/lsp/chat_commands_test.go | 41 |
1 files changed, 41 insertions, 0 deletions
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) + } +} |
