Skip to content

Commit 9bed28e

Browse files
committed
Fix test "should provide pattern match completions"
1 parent 3978bea commit 9bed28e

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

server/src/server.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from "./server";
1414
import {
1515
CompletionItem,
16+
CompletionItemKind,
1617
Hover,
1718
MarkupContent,
1819
Range,
@@ -199,7 +200,7 @@ result
199200
const completions = getCompletionItems(document, position);
200201

201202
const patternCompletions = completions.filter(
202-
(c) => c.kind === 14 && c.label.includes("->"), // Snippet kind
203+
(c) => c.kind === CompletionItemKind.Snippet && c.insertText?.includes("->"), // Snippet kind
203204
);
204205
expect(patternCompletions.length).toBeGreaterThan(0);
205206
});

server/src/server.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -683,19 +683,19 @@ function analyzeCompletionContext(
683683
return { type: "tag" };
684684
}
685685

686-
// Check for where clause context
687-
if (lineText.trim().startsWith(";") || findParentOfType(node, "where")) {
688-
return { type: "where_clause" };
689-
}
690-
691686
// Check for pattern match context
692687
if (
693688
lineText.trim().startsWith("|") ||
694-
findParentOfType(node, "pattern_match")
689+
findParentOfType(node, "match_fun")
695690
) {
696691
return { type: "pattern_match" };
697692
}
698693

694+
// Check for where clause context
695+
if (lineText.trim().startsWith(";") || findParentOfType(node, "where")) {
696+
return { type: "where_clause" };
697+
}
698+
699699
// Check for record field access
700700
if (lineText.includes(".") || parent?.type === "record_access") {
701701
return { type: "record_field" };

0 commit comments

Comments
 (0)