Skip to content

CmdPal: Fix bookmark launch fallback handling - #48712

Closed
michaeljolley wants to merge 17 commits into
mainfrom
dev/mjolley/squad/bookmark-path-handling
Closed

CmdPal: Fix bookmark launch fallback handling#48712
michaeljolley wants to merge 17 commits into
mainfrom
dev/mjolley/squad/bookmark-path-handling

Conversation

@michaeljolley

@michaeljolley michaeljolley commented Jun 18, 2026

Copy link
Copy Markdown
Contributor
  • update BookmarkResolver path probing/classification heuristics for bookmark strings with spaces, punctuation, and non-ASCII characters
  • add conservative percent-decoding (decode only when %xx sequences are present)
  • add NormalizePathForWindows (NFC normalization + safe long-path prefix stripping) before probe/classification use
  • require filesystem existence checks when selecting probe candidates; if exact target is missing, fall back to nearest existing parent directory and classify as Directory/ExplorerOpen
  • preserve URL/protocol/PATH-command behavior and keep launch behavior changes scoped to classification output

Fixes #48672

@michaeljolley michaeljolley added the Product-Command Palette Refers to the Command Palette utility label Jun 18, 2026
…ly tests (#48672)

- Extract NormalizePathForWindows from BookmarkResolver into a dedicated
  internal helper class (Services/PathNormalization.cs).
- Add safe trailing-whitespace trimming (incl. NBSP) so trailing copy/paste
  artifacts don't defeat File.Exists probes; trailing dots are deliberately
  preserved to avoid lossy transformations.
- BookmarkResolver delegates through a thin private wrapper so existing
  call sites and behavior are unchanged.
- Add PathNormalizationTests covering NFC, non-ASCII preservation,
  trailing-whitespace handling, and Windows-only long-path / NT-object
  prefix stripping. Windows-only assertions use Assert.Inconclusive on
  non-Windows agents so CI on Linux/macOS skips them cleanly.
@michaeljolley michaeljolley changed the title Fix bookmark launch fallback handling (#48672) CmdPal: Fix bookmark launch fallback handling (#48672) Jun 18, 2026
@michaeljolley michaeljolley changed the title CmdPal: Fix bookmark launch fallback handling (#48672) CmdPal: Fix bookmark launch fallback handling Jun 18, 2026

@michaeljolley michaeljolley left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

LGTM — approved by Duke

@michaeljolley michaeljolley left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

LGTM — approved by Cover Girl (QA) — tests added/updated and passing locally. See commit SHAs in your report.

@michaeljolley
michaeljolley marked this pull request as ready for review June 19, 2026 00:50
@michaeljolley
michaeljolley enabled auto-merge (squash) June 19, 2026 00:51
@michaeljolley michaeljolley self-assigned this Jun 19, 2026
- Remove reflection-based tests; use IProcessLauncher mock to capture
  launched classifications (proper use of the DI that the PR introduced)
- Simplify GreedyFind: replace List/HashSet/Sort allocations with a
  single for-loop that skips non-boundary positions
- Add missing 'using ManagedCommon' to PathHelpers.cs (compile fix)
- Replace bare catch blocks with Logger.LogError calls in
  TryResolvePathCandidateCore and TryPercentDecodePathCandidate

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@michaeljolley michaeljolley added Needs-Review This Pull Request awaits the review of a maintainer. CmdPal-Inbox Extensions labels Jun 24, 2026
michaeljolley and others added 2 commits June 24, 2026 10:13
Classification is a sealed record (reference type), not a struct.
Nullable reference types don't have .Value — access properties directly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@michaeljolley michaeljolley removed the Needs-Review This Pull Request awaits the review of a maintainer. label Jun 24, 2026
michaeljolley and others added 7 commits June 24, 2026 12:38
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…em call

A new call site was added on main that the PR didn't account for.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- BookmarksCommandProviderTests.cs: add #nullable enable for Classification? usage
- BookmarkResolverGreedyFindTests.cs: add using Microsoft.CmdPal.Ext.Bookmarks.Helpers for CommandKind

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The resolver should classify paths by their extension/existence without
falling back to parent directories. Parent-fallback belongs only in
LaunchBookmarkCommand at launch time. This fixes test failures where
non-existing files with extensions were incorrectly classified as
Directory.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…arators

Probing at path-separator boundaries caused GreedyFind to walk up to
ancestor directories (e.g. C:\Users) for non-existing paths, incorrectly
classifying quoted paths like "C:\Users\John Doe\file.txt" as Directory
instead of letting them fall through to the LooksPathy heuristic which
correctly classifies by extension.

Also simplifies ExpandToBestExistingPath return type (removes vestigial
UsedParentDirectoryFallback bool that was always false).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Preserve the raw command token for the Unknown fallback target in
  BookmarkResolver so normalization no longer trims meaningful trailing
  whitespace (e.g. a quoted single space). Normalization is now applied
  to a separate copy used only for path detection/probing.
- Make MockProcessLauncher mirror the real launcher by failing for a
  filesystem target that does not exist, which is what drives the
  nearest-existing-parent fallback the test asserts.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@michaeljolley michaeljolley added the Needs-Review This Pull Request awaits the review of a maintainer. label Jun 26, 2026

@jiripolasek jiripolasek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Blocking this until we figure out what's going on here

auto-merge was automatically disabled July 1, 2026 03:54

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CmdPal-Inbox Extensions Needs-Review This Pull Request awaits the review of a maintainer. Product-Command Palette Refers to the Command Palette utility

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Command palette : incorrect path

2 participants