Skip to content

Make the @-file picker complete, deterministic and active-tab-first#209

Open
leonidasbarkas98-cpu wants to merge 1 commit into
andrepimenta:mainfrom
leonidasbarkas98-cpu:fix/file-picker-deterministic
Open

Make the @-file picker complete, deterministic and active-tab-first#209
leonidasbarkas98-cpu wants to merge 1 commit into
andrepimenta:mainfrom
leonidasbarkas98-cpu:fix/file-picker-deterministic

Conversation

@leonidasbarkas98-cpu

Copy link
Copy Markdown

The @-file picker collected files with findFiles(..., 500) on every keystroke. The 500-results cap truncated the candidate set before filtering, so files beyond it were unreachable (#58); findFiles returns results in unspecified order, so each call produced a different 500-subset — non-deterministic lists (#24); sorting by basename only left equal names in that unspecified order (#23); and the active editor tab was not considered at all (#53).

Changes:

  • Collect once per picker opening into a cache (refreshed on every empty search term) with maxResults 10000; keystrokes filter the cached snapshot instead of re-running findFiles.
  • The nine hard-coded excludes are merged with the user's files.exclude/search.exclude entries (patterns containing ,{} are skipped so one exotic pattern cannot corrupt the combined glob).
  • Relevance scoring (exact name / prefix / name substring / path substring) replaces the plain includes filter; ties break on the relative path compared by codepoint — a total order, so identical input yields the identical list. The 50-result slice now applies after ranking.
  • The active editor tab (file scheme only, case-insensitive on win32) is pinned to the top of the ranked list; it is never force-added when outside the workspace or filtered out.

The webview payload shape is unchanged — no renderer change.

Addresses #58, #24, #23 and #53. Based on current main (ab6e307), tsc --noEmit clean, no new dependencies.

The picker collected files with findFiles(..., 500) on every keystroke:
the 500-results cap truncated the candidate set BEFORE filtering (files
beyond it were unreachable, andrepimenta#58), findFiles returns results in
unspecified order so each call produced a different 500-subset
(non-deterministic lists, andrepimenta#24), and sorting by basename only left equal
names in that unspecified order (andrepimenta#23). The active editor tab was not
considered at all (andrepimenta#53).

- collect once per picker opening into _workspaceFileCache (refreshed
  on every empty searchTerm, i.e. whenever the picker opens) with
  maxResults 10000 so the cap practically never bites; keystrokes now
  filter the cached snapshot instead of re-running findFiles,
- excludes move to _buildExcludeGlob(): the previous nine defaults
  merged with the user's files.exclude/search.exclude entries (only
  values === true; patterns containing , { } are skipped so a single
  exotic pattern cannot corrupt the combined {a,b,...} glob),
- relevance scoring (exact name 100 / prefix 90 / name substring 80 /
  path substring 60) replaces the plain includes filter; ties break on
  the relative path compared by codepoint (no localeCompare) — a total
  order, so identical input yields the identical list; slice(0, 50)
  now applies after ranking,
- the active editor tab (file scheme only, matched via asRelativePath,
  case-insensitive on win32) is moved to the top of the ranked list;
  it is never force-added when outside the workspace or filtered out,
- webview payload stays {name, path, fsPath} — no renderer change.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant