Skip to content

fix: keep directory separators visible when filtering npm scripts#2370

Open
patrickiel wants to merge 1 commit into
microsoft:mainfrom
patrickiel:fix/npm-script-quickpick-keep-separators
Open

fix: keep directory separators visible when filtering npm scripts#2370
patrickiel wants to merge 1 commit into
microsoft:mainfrom
patrickiel:fix/npm-script-quickpick-keep-separators

Conversation

@patrickiel
Copy link
Copy Markdown

@patrickiel patrickiel commented Jun 7, 2026

Problem

The Debug npm Script picker (extension.js-debug.npmScript) groups scripts by directory using QuickPickItemKind.Separator when scripts come from multiple directories (multi-root / monorepo workspaces). While filtering, the quick pick sorts items by match position (VS Code's default), which reorders items across groups and drops the separators. As soon as you type a filter, you can no longer tell which package each script belongs to.

  • Unfiltered: scripts grouped with the directory name shown on the right ✔️
  • Filtered (before): directory labels disappear ❌
  • Filtered (after): directory labels stay attached to their groups ✔️

Fix

Disable match sorting only when scripts span multiple directories (multiDir), so the separators stay attached while filtering. Single-directory pickers keep the default match sorting and are unchanged.

   const quickPick = vscode.window.createQuickPick<ScriptPickItem>();
+  (quickPick as { sortByLabel?: boolean }).sortByLabel = !multiDir;

sortByLabel is a proposed API (microsoft/vscode#73904) but is safe to set at runtime (the setter has no proposal guard). The change uses a typed cast to avoid taking a proposed-API dependency, matching the existing cast style in the codebase (e.g. objectPreview/index.ts).

Screenshot 2026-06-07 070414 Screenshot 2026-06-07 081932

@patrickiel patrickiel force-pushed the fix/npm-script-quickpick-keep-separators branch from e2fa550 to 3aa6687 Compare June 7, 2026 06:03
The "Debug npm script" quick pick groups scripts by directory using
separators in multi-root / monorepo workspaces. The quick pick sorts by
match position while filtering (the default), so typing a filter reorders
items across groups and drops the separators - the user can no longer tell
which package each script belongs to.

Disable match sorting only when scripts span multiple directories, so the
separators stay attached to their groups while filtering. Single-directory
pickers keep the default match sorting.
@patrickiel patrickiel force-pushed the fix/npm-script-quickpick-keep-separators branch from 3aa6687 to e2ba5c5 Compare June 7, 2026 06:11
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