summaryrefslogtreecommitdiff
path: root/internal/lsp/server_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/lsp/server_test.go')
-rw-r--r--internal/lsp/server_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/lsp/server_test.go b/internal/lsp/server_test.go
index 4f24b57..836e43f 100644
--- a/internal/lsp/server_test.go
+++ b/internal/lsp/server_test.go
@@ -85,3 +85,20 @@ func TestServerApplyOptions(t *testing.T) {
t.Fatalf("expected config to update, got %d", got)
}
}
+
+func TestServerStoreAndTakePendingCompletion(t *testing.T) {
+ s := newTestServer()
+ items := []CompletionItem{{Label: "foo"}}
+ s.storePendingCompletion("key", items)
+ if len(s.pendingCompletions) != 1 {
+ t.Fatalf("expected pending map to be populated")
+ }
+ items[0].Label = "bar" // ensure copy stored
+ got := s.takePendingCompletion("key")
+ if len(got) != 1 || got[0].Label != "foo" {
+ t.Fatalf("expected preserved copy of completion, got %+v", got)
+ }
+ if len(s.pendingCompletions) != 0 {
+ t.Fatalf("expected pending map to be cleared after take")
+ }
+}