Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions vscode-extension/src/slash-command-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,18 @@ export class SlashCommandService {
private sortResults(results: SlashCommand[], query: string): void {
const lowerQuery = query.toLowerCase();

// ⚑ Bolt: Pre-compute Set for O(1) recency lookups instead of O(N) Array.includes during sort
const recentSet = new Set(this.recentlyUsed);

results.sort((a, b) => {
const aExact = a.name === lowerQuery;
const bExact = b.name === lowerQuery;

if (aExact && !bExact) return -1;
if (!aExact && bExact) return 1;

const aRecent = this.recentlyUsed.includes(a.name.toLowerCase());
const bRecent = this.recentlyUsed.includes(b.name.toLowerCase());
const aRecent = recentSet.has(a.name.toLowerCase());
const bRecent = recentSet.has(b.name.toLowerCase());

if (aRecent && !bRecent) return -1;
if (!aRecent && bRecent) return 1;
Expand Down
Loading