Skip to content

Commit ee2120f

Browse files
committed
Fix test "should provide pattern match completions"
1 parent 547eed0 commit ee2120f

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

server/src/server.test.ts

Lines changed: 3 additions & 2 deletions
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,
@@ -197,11 +198,11 @@ result
197198
});
198199

199200
it("should provide pattern match completions", () => {
200-
const position = { line: 10, character: 4 }; // After "|"
201+
const position = { line: 12, character: 4 }; // After "|"
201202
const completions = getCompletionItems(document, position);
202203

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

server/src/server.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -677,19 +677,19 @@ function analyzeCompletionContext(
677677
return { type: "tag" };
678678
}
679679

680-
// Check for where clause context
681-
if (lineText.trim().startsWith(";") || findParentOfType(node, "where")) {
682-
return { type: "where_clause" };
683-
}
684-
685680
// Check for pattern match context
686681
if (
687682
lineText.trim().startsWith("|") ||
688-
findParentOfType(node, "pattern_match")
683+
findParentOfType(node, "match_fun")
689684
) {
690685
return { type: "pattern_match" };
691686
}
692687

688+
// Check for where clause context
689+
if (lineText.trim().startsWith(";") || findParentOfType(node, "where")) {
690+
return { type: "where_clause" };
691+
}
692+
693693
// Check for record field access
694694
if (lineText.includes(".") || parent?.type === "record_access") {
695695
return { type: "record_field" };

0 commit comments

Comments
 (0)