Skip to content

Fix burst search dropping valid results due to early cutoff#253

Merged
AhmmedSamier merged 5 commits intomasterfrom
codex/fix-search-result-indexing-issues
Mar 3, 2026
Merged

Fix burst search dropping valid results due to early cutoff#253
AhmmedSamier merged 5 commits intomasterfrom
codex/fix-search-result-indexing-issues

Conversation

@AhmmedSamier
Copy link
Copy Markdown
Owner

@AhmmedSamier AhmmedSamier commented Mar 3, 2026

Motivation

  • Users observed search results appearing/disappearing across reindex cycles because burst search could stop scanning early and miss valid matches.
  • The root cause was short-circuiting candidate collection during scope traversal which caused scope-order starvation and inconsistent streaming vs returned results.

Description

  • Changed language-server/src/core/search-engine.ts so burstSearch first collects all matching candidates (via findBurstMatches) and then ranks and truncates using results.sort(...).slice(0, maxResults) instead of stopping during traversal.
  • Moved streaming callback emission (onResult) to occur after ranking/truncation so streamed notifications match the final returned results.
  • Simplified traversal helpers by removing maxResults/results short-circuiting and updated signatures for findBurstMatches, searchAllScopesInPriorityOrder, searchPriorityScopes, and searchRemainingItems to respect only cancellation tokens.
  • Added a regression test should prefer best-scoring result across all scopes in burstSearch in language-server/src/core/search-engine.test.ts to ensure best-scoring matches from non-priority scopes are returned.

Testing

  • Ran unit tests with cd language-server && bun run test and cd language-server && bun test and observed all tests pass (including the new regression test).
  • Built the extension with cd vscode-extension && bun run compile to verify packaging and artifacts copy completed successfully.
  • Also ran the focused test run cd language-server && bun test src/core/search-engine.test.ts to validate the specific changes and the new test passed.

Codex Task

Summary by CodeRabbit

  • New Features

    • Lexical scoring to favor exact-name and dispersed-word matches; search orchestration now prunes and ranks earlier for better relevance and performance.
    • Result delivery centralized and cancellation-aware, with post-sort boosting and stable ordering.
  • Bug Fixes

    • Ensures the highest-scoring match wins across scopes and when results are limited.
  • Tests

    • Added tests verifying direct-name prioritization and best-result selection across scopes.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 3, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds lexical/name-based scoring alongside fuzzy scoring, introduces query bitflag pruning in hot paths, moves result emission and slicing out of burst hot paths into a cancellation-aware post-processing pipeline, and adds tests ensuring direct/lexical matches beat weaker fuzzy matches across scopes.

Changes

Cohort / File(s) Summary
Tests
language-server/src/core/search-engine.test.ts
Adds tests asserting direct/lexical CLASS name matches are preferred over weaker fuzzy endpoint matches and that burstSearch across scopes returns the single best-scoring result; duplicates the best-result scenario in two test contexts.
Search Engine Core
language-server/src/core/search-engine.ts
Increases FILE item boost, adds lexical/name and dispersed-word lexical scoring path merged with fuzzy scoring, introduces query bitflag pruning in hot-path processing, removes in-burst onResult emission and maxResults gating, centralizes cancellation handling, and defers ranking/boosting/post-processing (including URL matches and personalization) to a post-sort pipeline.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client
    participant SearchEngine as SearchEngine
    participant BurstLayer as BurstLayer
    participant ProviderIndex as ProviderIndex
    participant URLMatcher as URLMatcher
    participant PostProcess as PostProcess

    Client->>SearchEngine: search(query, maxResults, token)
    SearchEngine->>BurstLayer: findBurstMatches(queryLower, token, queryBits)
    BurstLayer->>ProviderIndex: probe providers/indexes (bitflag-pruned)
    ProviderIndex-->>BurstLayer: rawMatches (lexical + fuzzy scores)
    BurstLayer-->>SearchEngine: burstMatches
    SearchEngine->>URLMatcher: addUrlMatches(burstMatches, preparedQuery)
    URLMatcher-->>SearchEngine: mergedMatches
    SearchEngine->>PostProcess: rankAndBoost(mergedMatches, personalization, activity)
    PostProcess-->>SearchEngine: finalRankedResults
    SearchEngine->>Client: emit results (sliced to maxResults, cancellation-aware)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇
I hopped through names and fuzzy streams,
Chased the clearest, brightest beams.
Boosted, pruned, and chose the best —
A tidy match beneath my vest. ✨🔎

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly summarizes the main bug fix: addressing burst search dropping valid results due to early cutoff, which is the core motivation and primary change in the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/fix-search-result-indexing-issues

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
language-server/src/core/search-engine.ts (1)

2100-2105: ⚠️ Potential issue | 🟠 Major

URL augmentation still short-circuits candidate collection.

At Line 2104, addUrlMatches(..., maxResults) can stop scanning URL candidates early, which can still drop valid high-scoring endpoint matches before final ranking.

Suggested fix
-            this.addUrlMatches(results, indices, preparedQuery, maxResults);
+            this.addUrlMatches(results, indices, preparedQuery, cancellationToken);
-    private addUrlMatches(
-        results: SearchResult[],
-        indices: number[] | undefined,
-        queryOrPrepared: string | PreparedPath,
-        maxResults?: number,
-    ): void {
+    private addUrlMatches(
+        results: SearchResult[],
+        indices: number[] | undefined,
+        queryOrPrepared: string | PreparedPath,
+        token?: CancellationToken,
+    ): void {
         const existingIds = new Set(results.map((r) => r.item.id));

         const checkItem = (i: number) => {
-            if (maxResults && results.length >= maxResults) return;
+            if (token?.isCancellationRequested) return;

             const item = this.items[i];
             if (item.type === SearchItemType.ENDPOINT && !existingIds.has(item.id)) {
                 const pattern = this.preparedPatterns[i];
                 const score = pattern
                     ? RouteMatcher.scoreMatchPattern(pattern, queryOrPrepared)
                     : RouteMatcher.scoreMatch(item.name, queryOrPrepared);

                 if (score > 0) {
                     results.push({
                         item,
                         score,
                         scope: SearchScope.ENDPOINTS,
                     });
                     existingIds.add(item.id);
                 }
             }
         };

         if (indices) {
             for (const i of indices) {
-                if (maxResults && results.length >= maxResults) break;
+                if (token?.isCancellationRequested) break;
                 checkItem(i);
             }
         } else {
             for (let i = 0; i < this.items.length; i++) {
-                if (maxResults && results.length >= maxResults) break;
+                if (token?.isCancellationRequested) break;
                 checkItem(i);
             }
         }
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@language-server/src/core/search-engine.ts` around lines 2100 - 2105, The URL
augmentation path calls this.addUrlMatches(results, indices, preparedQuery,
maxResults) which allows addUrlMatches to short-circuit candidate collection and
drop endpoint candidates prematurely; change the call to collect all URL
candidates (e.g., remove the maxResults limit or pass a very large limit such as
Number.MAX_SAFE_INTEGER) so addUrlMatches (referenced by name) scans fully,
letting the final ranking step decide which matches to keep; keep the same
condition around RouteMatcher.prepare/queryLower and ensure downstream ranking
logic still enforces maxResults.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@language-server/src/core/search-engine.ts`:
- Around line 2100-2105: The URL augmentation path calls
this.addUrlMatches(results, indices, preparedQuery, maxResults) which allows
addUrlMatches to short-circuit candidate collection and drop endpoint candidates
prematurely; change the call to collect all URL candidates (e.g., remove the
maxResults limit or pass a very large limit such as Number.MAX_SAFE_INTEGER) so
addUrlMatches (referenced by name) scans fully, letting the final ranking step
decide which matches to keep; keep the same condition around
RouteMatcher.prepare/queryLower and ensure downstream ranking logic still
enforces maxResults.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cb331f2 and 1aaa144.

📒 Files selected for processing (2)
  • language-server/src/core/search-engine.test.ts
  • language-server/src/core/search-engine.ts

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@language-server/src/core/search-engine.ts`:
- Around line 2099-2105: Before calling RouteMatcher.prepare and
this.addUrlMatches, check the search cancellation token and return early if
cancellation was requested; i.e., in the block that tests (scope ===
SearchScope.EVERYTHING || scope === SearchScope.ENDPOINTS) &&
RouteMatcher.isPotentialUrl(queryLower) add a guard (check the existing
cancellation variable or method used across the class, e.g.,
cancellation.isCancellationRequested or this.isCancelled()) and skip creating
preparedQuery and calling this.addUrlMatches(results, indices, preparedQuery)
when cancelled.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1aaa144 and 272942e.

📒 Files selected for processing (1)
  • language-server/src/core/search-engine.ts

Comment thread language-server/src/core/search-engine.ts Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
language-server/src/core/search-engine.ts (1)

2125-2131: ⚠️ Potential issue | 🟠 Major

Honor cancellation before URL augmentation in burstSearch.

Line 2125 still performs URL expansion even after cancellation. This can continue scanning endpoints after cancellation is requested.

Suggested fix
-        if (
+        if (
+            !cancellationToken?.isCancellationRequested &&
             (scope === SearchScope.EVERYTHING || scope === SearchScope.ENDPOINTS) &&
             RouteMatcher.isPotentialUrl(queryLower)
         ) {
             const preparedQuery = RouteMatcher.prepare(queryLower);
-            this.addUrlMatches(results, indices, preparedQuery);
+            this.addUrlMatches(results, indices, preparedQuery, cancellationToken);
         }
     private addUrlMatches(
         results: SearchResult[],
         indices: number[] | undefined,
         queryOrPrepared: string | PreparedPath,
-        maxResults?: number,
+        token?: CancellationToken,
     ): void {
         const existingIds = new Set(results.map((r) => r.item.id));

         const checkItem = (i: number) => {
-            if (maxResults && results.length >= maxResults) return;
+            if (token?.isCancellationRequested) return;

             const item = this.items[i];
             if (item.type === SearchItemType.ENDPOINT && !existingIds.has(item.id)) {
                 const pattern = this.preparedPatterns[i];
@@
         if (indices) {
             for (const i of indices) {
-                if (maxResults && results.length >= maxResults) break;
+                if (token?.isCancellationRequested) break;
                 checkItem(i);
             }
         } else {
             for (let i = 0; i < this.items.length; i++) {
-                if (maxResults && results.length >= maxResults) break;
+                if (token?.isCancellationRequested) break;
                 checkItem(i);
             }
         }
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@language-server/src/core/search-engine.ts` around lines 2125 - 2131, In
burstSearch, avoid doing URL expansion after cancellation by checking the search
cancellation token/abort signal immediately before the URL-augmentation block:
when (scope === SearchScope.EVERYTHING || scope === SearchScope.ENDPOINTS) &&
RouteMatcher.isPotentialUrl(queryLower) is true, first test the cancellation
token (e.g., cancelToken.isCancelled or abortSignal.aborted) and return/skip if
cancelled, then call RouteMatcher.prepare and this.addUrlMatches; update the
burstSearch implementation to perform this early-cancel check so
RouteMatcher.prepare and addUrlMatches are not invoked after cancellation.
🧹 Nitpick comments (1)
language-server/src/core/search-engine.ts (1)

1753-1805: Avoid per-item toLowerCase() allocations in the lexical hot path.

calculateLexicalScore lowercases names on every candidate evaluation. On large indices, this can become a measurable regression. Consider using precomputed lowercase fields (parallel arrays) to keep this path allocation-free.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@language-server/src/core/search-engine.ts` around lines 1753 - 1805,
calculateLexicalScore currently calls item.name.toLowerCase() per candidate;
avoid that allocation by precomputing lowercase strings in prepareSearchContext
and reading them from the context. Update prepareSearchContext to build parallel
arrays (e.g., context.namesLower and context.fullNamesLower) or attach lowercase
fields to each item when the search context is prepared, ensure they are
populated when the index is created/updated, then change calculateLexicalScore
to use context.namesLower[i] and context.fullNamesLower[i] (and still use
context.queryLower) instead of calling toLowerCase on item.name/fullName so the
lexical hot path is allocation-free; keep the same fallback/score logic and
preserve use of ID_TO_BOOST.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@language-server/src/core/search-engine.ts`:
- Around line 2125-2131: In burstSearch, avoid doing URL expansion after
cancellation by checking the search cancellation token/abort signal immediately
before the URL-augmentation block: when (scope === SearchScope.EVERYTHING ||
scope === SearchScope.ENDPOINTS) && RouteMatcher.isPotentialUrl(queryLower) is
true, first test the cancellation token (e.g., cancelToken.isCancelled or
abortSignal.aborted) and return/skip if cancelled, then call
RouteMatcher.prepare and this.addUrlMatches; update the burstSearch
implementation to perform this early-cancel check so RouteMatcher.prepare and
addUrlMatches are not invoked after cancellation.

---

Nitpick comments:
In `@language-server/src/core/search-engine.ts`:
- Around line 1753-1805: calculateLexicalScore currently calls
item.name.toLowerCase() per candidate; avoid that allocation by precomputing
lowercase strings in prepareSearchContext and reading them from the context.
Update prepareSearchContext to build parallel arrays (e.g., context.namesLower
and context.fullNamesLower) or attach lowercase fields to each item when the
search context is prepared, ensure they are populated when the index is
created/updated, then change calculateLexicalScore to use context.namesLower[i]
and context.fullNamesLower[i] (and still use context.queryLower) instead of
calling toLowerCase on item.name/fullName so the lexical hot path is
allocation-free; keep the same fallback/score logic and preserve use of
ID_TO_BOOST.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 272942e and b925b37.

📒 Files selected for processing (2)
  • language-server/src/core/search-engine.test.ts
  • language-server/src/core/search-engine.ts

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
language-server/src/core/search-engine.ts (1)

2129-2135: ⚠️ Potential issue | 🟠 Major

Honor cancellation before URL augmentation work.

When cancellation is already requested, RouteMatcher.prepare(...) and addUrlMatches(...) still run. This can continue scanning after cancel and delay responsiveness.

Suggested fix
-        if (
+        if (
+            !cancellationToken?.isCancellationRequested &&
             (scope === SearchScope.EVERYTHING || scope === SearchScope.ENDPOINTS) &&
             RouteMatcher.isPotentialUrl(queryLower)
         ) {
             const preparedQuery = RouteMatcher.prepare(queryLower);
-            this.addUrlMatches(results, indices, preparedQuery);
+            this.addUrlMatches(results, indices, preparedQuery, cancellationToken);
         }
     private addUrlMatches(
         results: SearchResult[],
         indices: number[] | undefined,
         queryOrPrepared: string | PreparedPath,
-        maxResults?: number,
+        token?: CancellationToken,
     ): void {
@@
-            if (maxResults && results.length >= maxResults) return;
+            if (token?.isCancellationRequested) return;
@@
         if (indices) {
             for (const i of indices) {
-                if (maxResults && results.length >= maxResults) break;
+                if (token?.isCancellationRequested) break;
                 checkItem(i);
             }
         } else {
             for (let i = 0; i < this.items.length; i++) {
-                if (maxResults && results.length >= maxResults) break;
+                if (token?.isCancellationRequested) break;
                 checkItem(i);
             }
         }
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@language-server/src/core/search-engine.ts` around lines 2129 - 2135, Before
performing URL augmentation, check the search cancellation flag/token and bail
out early if cancellation is requested; specifically, inside the block that
checks SearchScope.EVERYTHING/ENDPOINTS and
RouteMatcher.isPotentialUrl(queryLower), verify the cancellation state (e.g.,
this.cancellationRequested or the provided
cancellationToken/isCancellationRequested) and return without calling
RouteMatcher.prepare(...) or this.addUrlMatches(results, indices, ... ) when
cancelled so the expensive prepare/addUrlMatches work is skipped.
🧹 Nitpick comments (1)
language-server/src/core/search-engine.ts (1)

1758-1762: Avoid per-item lowercase allocations in lexical scoring hot path.

calculateLexicalScore currently lowercases item.name (and may lowercase fullName downstream) for every scanned item per query. Caching lowercased name/fullName in parallel arrays would reduce GC pressure on large indexes.

Also applies to: 1789-1809

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@language-server/src/core/search-engine.ts` around lines 1758 - 1762,
calculateLexicalScore is allocating lowercased strings per-item on every query
which pressures the GC; precompute and reuse lowercased versions instead. Add
parallel arrays (e.g., lowerNames and lowerFullNames) populated once when the
item index is built/updated and replace all per-call
item.name.toLowerCase()/fullName.toLowerCase() usages inside
calculateLexicalScore (and related code paths referenced around
calculateLexicalScore and lines 1789-1809) to read from those arrays; ensure the
arrays are kept in sync with the main items array when items are
added/removed/updated so calculateFuzzyScore and other callers continue to use
the original item data while lexical scoring uses cached lowercase strings.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@language-server/src/core/search-engine.ts`:
- Around line 2129-2135: Before performing URL augmentation, check the search
cancellation flag/token and bail out early if cancellation is requested;
specifically, inside the block that checks SearchScope.EVERYTHING/ENDPOINTS and
RouteMatcher.isPotentialUrl(queryLower), verify the cancellation state (e.g.,
this.cancellationRequested or the provided
cancellationToken/isCancellationRequested) and return without calling
RouteMatcher.prepare(...) or this.addUrlMatches(results, indices, ... ) when
cancelled so the expensive prepare/addUrlMatches work is skipped.

---

Nitpick comments:
In `@language-server/src/core/search-engine.ts`:
- Around line 1758-1762: calculateLexicalScore is allocating lowercased strings
per-item on every query which pressures the GC; precompute and reuse lowercased
versions instead. Add parallel arrays (e.g., lowerNames and lowerFullNames)
populated once when the item index is built/updated and replace all per-call
item.name.toLowerCase()/fullName.toLowerCase() usages inside
calculateLexicalScore (and related code paths referenced around
calculateLexicalScore and lines 1789-1809) to read from those arrays; ensure the
arrays are kept in sync with the main items array when items are
added/removed/updated so calculateFuzzyScore and other callers continue to use
the original item data while lexical scoring uses cached lowercase strings.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b925b37 and 8f350ed.

📒 Files selected for processing (1)
  • language-server/src/core/search-engine.ts

@AhmmedSamier AhmmedSamier force-pushed the codex/fix-search-result-indexing-issues branch from 8f350ed to 8d1a82b Compare March 3, 2026 21:09
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
language-server/src/core/search-engine.ts (1)

2175-2180: ⚠️ Potential issue | 🟠 Major

Cancellation is pre-checked before URL enrichment, but not honored during URL scanning.

After the one-time check in enrichResults, addUrlMatches can still scan all items even if cancellation flips mid-loop.

💡 Proposed fix
 private async enrichResults(
     results: SearchResult[],
     scope: SearchScope,
     queryLower: string,
     token?: CancellationToken,
 ): Promise<SearchResult[]> {
@@
         if (token?.isCancellationRequested) {
             return results;
         }
         const preparedQuery = RouteMatcher.prepare(queryLower);
-        this.addUrlMatches(results, undefined, preparedQuery);
+        this.addUrlMatches(results, undefined, preparedQuery, undefined, token);
     }

     return results;
 }
 private addUrlMatches(
     results: SearchResult[],
     indices: number[] | undefined,
     queryOrPrepared: string | PreparedPath,
     maxResults?: number,
+    token?: CancellationToken,
 ): void {
@@
     const checkItem = (i: number) => {
+        if (token?.isCancellationRequested) return;
         if (maxResults && results.length >= maxResults) return;
@@
     if (indices) {
         for (const i of indices) {
+            if (token?.isCancellationRequested) break;
             if (maxResults && results.length >= maxResults) break;
             checkItem(i);
         }
     } else {
         for (let i = 0; i < this.items.length; i++) {
+            if (token?.isCancellationRequested) break;
             if (maxResults && results.length >= maxResults) break;
             checkItem(i);
         }
     }
 }

Also applies to: 2365-2404

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@language-server/src/core/search-engine.ts` around lines 2175 - 2180,
enrichResults does a one-time cancellation check but then calls addUrlMatches
which can still fully scan items if cancellation occurs mid-loop; modify
addUrlMatches (and any other scanning helpers invoked from enrichResults, e.g.,
the scanning block referenced around lines 2365-2404) to accept the cancellation
token (token) and check token.isCancellationRequested inside its iteration(s),
returning early when canceled; update enrichResults to pass the token through
when calling addUrlMatches so cancellation is honored during URL scanning.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@language-server/src/core/search-engine.ts`:
- Around line 2236-2243: The current calculateMatchScore early-returns whenever
calculateNameMatchScore(nameLower, queryLower) > 0, which can under-rank
stronger fullName matches; change calculateMatchScore to always compute both
nameScore and fullNameScore (call calculateFullNameMatchScore(fullName,
nameLower, queryLower)) and return the higher of the two; also fix
calculateFullNameMatchScore to compare actual string equality instead of using
length equality (use fullName === nameLower or fullName === queryLower as
appropriate) so exact fullName matches aren't suppressed by length checks;
update references to calculateNameMatchScore and calculateFullNameMatchScore
accordingly.
- Around line 1729-1732: The current bitflag pruning uses context.queryBitflags
vs context.itemBitflags[i] and is too strict for pattern-based endpoints (e.g.,
/users/42 vs /users/{id}); change the comparison so that before early-return you
mask out dynamic-character flags (digits and punctuation) from the query
bitflags when evaluating pattern endpoints — compute maskedQuery =
context.queryBitflags & ~DYNAMIC_CHAR_FLAGS (using existing flag constants like
FLAG_DIGIT/FLAG_PUNCTUATION) and then require (context.itemBitflags[i] &
maskedQuery) === maskedQuery; apply the same masked comparison in the other
occurrence around lines 2205-2208 so pattern endpoints aren’t incorrectly
pruned.

---

Duplicate comments:
In `@language-server/src/core/search-engine.ts`:
- Around line 2175-2180: enrichResults does a one-time cancellation check but
then calls addUrlMatches which can still fully scan items if cancellation occurs
mid-loop; modify addUrlMatches (and any other scanning helpers invoked from
enrichResults, e.g., the scanning block referenced around lines 2365-2404) to
accept the cancellation token (token) and check token.isCancellationRequested
inside its iteration(s), returning early when canceled; update enrichResults to
pass the token through when calling addUrlMatches so cancellation is honored
during URL scanning.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8f350ed and 8d1a82b.

📒 Files selected for processing (1)
  • language-server/src/core/search-engine.ts

Comment thread language-server/src/core/search-engine.ts
Comment thread language-server/src/core/search-engine.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant