File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,7 @@ const CAMEL_OR_PASCAL_PATTERN = /\b[A-Za-z_$][A-Za-z0-9_$]*\b/g;
119119const SNAKE_PATTERN = / \b [ a - z 0 - 9 ] + _ [ a - z 0 - 9 _ ] + \b / g;
120120const KEBAB_PATTERN = / \b [ a - z 0 - 9 ] + - [ a - z 0 - 9 - ] + \b / g;
121121const BACKTICK_IDENTIFIER_PATTERN = / ` ( [ ^ ` ] + ) ` / g;
122+ const BACKTICK_IDENTIFIER_PRESENCE_PATTERN = / ` ( [ ^ ` ] + ) ` / ;
122123
123124function 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
156157function 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
160161function looksLikeDirectPath ( text : string ) : boolean {
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments