Skip to content

Commit cdc52a7

Browse files
committed
test: cover repeated backticked identifier routing
1 parent 222fde4 commit cdc52a7

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/routing-hints.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ const CAMEL_OR_PASCAL_PATTERN = /\b[A-Za-z_$][A-Za-z0-9_$]*\b/g;
119119
const SNAKE_PATTERN = /\b[a-z0-9]+_[a-z0-9_]+\b/g;
120120
const KEBAB_PATTERN = /\b[a-z0-9]+-[a-z0-9-]+\b/g;
121121
const BACKTICK_IDENTIFIER_PATTERN = /`([^`]+)`/g;
122+
const BACKTICK_IDENTIFIER_PRESENCE_PATTERN = /`([^`]+)`/;
122123

123124
function normalizeText(text: string): string {
124125
return text.trim().replace(/\s+/g, " ");
@@ -149,12 +150,12 @@ function hasIdentifierShape(text: string): boolean {
149150
return false;
150151
}
151152

152-
return /[A-Z]/.test(match) || match.includes("_") || match.includes("-") || /`/.test(text);
153+
return /[A-Z]/.test(match) || match.includes("_") || match.includes("-") || /`/.test(match);
153154
});
154155
}
155156

156157
function containsQuotedIdentifier(text: string): boolean {
157-
return BACKTICK_IDENTIFIER_PATTERN.test(text) || /"[^"]+"/.test(text) || /'[^']+'/.test(text);
158+
return BACKTICK_IDENTIFIER_PRESENCE_PATTERN.test(text) || /"[^"]+"/.test(text) || /'[^']+'/.test(text);
158159
}
159160

160161
function looksLikeDirectPath(text: string): boolean {

tests/routing-hints.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ describe("routing hints", () => {
3434
expect(assessment.intent).toBe("exact_identifier");
3535
});
3636

37+
it("does not alternate exact-identifier detection for repeated backticked queries", () => {
38+
const first = assessRoutingIntent("Find all references to `validateToken`");
39+
const second = assessRoutingIntent("Find all references to `otherSymbol`");
40+
const third = assessRoutingIntent("Find all references to `validateToken`");
41+
42+
expect(first.intent).toBe("exact_identifier");
43+
expect(second.intent).toBe("exact_identifier");
44+
expect(third.intent).toBe("exact_identifier");
45+
});
46+
3747
it("detects definition lookups separately from conceptual discovery", () => {
3848
const assessment = assessRoutingIntent("Where is the payment handler defined?");
3949

0 commit comments

Comments
 (0)