Open
Conversation
aea831a to
e645459
Compare
DavisVaughan
approved these changes
Mar 5, 2026
| }, | ||
| }; | ||
|
|
||
| let uri = Url::from_file_path(&path).unwrap_or(uri); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes breakpoint tests skipped in posit-dev/positron#12119. The frontend tests run from a temporary folder, and the way we handled URIs caused verification mismatches because temp paths go through symlinks on macOS.
File URIs for the same file arrive from four independent sources, each with its own representation: DAP (file paths from the frontend), LSP (editor URIs), execute requests (editor document model URIs), and the R runtime (paths that went through
normalizePath(), resolving symlinks). These must all agree on file identity because breakpoints set via DAP are looked up in a HashMap keyed by URI when code is executed or sourced, and invalidated when documents change via LSP.Previously,
ExtUrl::normalize()only handled the Windows encoding issue (file:///c%3A/...vsfile:///C:/...) and was a no-op on other platforms.ExtUrl::from_file_path()did resolve symlinks, butfrom_urlpaths (LSP, execute requests) did not. On macOS,/var/foldersis a symlink to/private/var/folders, andtempfile::tempdir()creates directories under/var/folders. So breakpoints set via DAP (which canonicalized throughfrom_file_path) would use/private/var/...as the key, while execute request URIs (which came straight from the editor) would look up/var/...and miss.New
UrlIdtypeThis PR replaces
ExtUrl::normalize()with aUrlIdtype that canonicalizes file URIs on all platforms.UrlIdwraps aUrlthat has been throughstd::fs::canonicalize()to resolve symlinks and round-tripped through the filesystem path to normalize encoding. It also makes sure the drive letter on Windows is uppercased.UrlIdis constructed at every entry point where a URI will be used as an identity key:UrlId::from_file_path()for DAPSetBreakpointspathsUrlId::from_url()for LSPdidChangeURIsUrlId::from_code_location()for execute request URIsUrlId::parse()for URI strings from R callbacksThe
breakpointsHashMap inDapis now keyed byUrlIdinstead ofUrl, and all lookup/mutation sites useUrlId. When the file doesn't exist on disk, canonicalization falls back to the original URI.Canonical URIs must not leak back to R or the frontend. An early version of this branch canonicalized URIs everywhere, which caused the frontend to open files in new editors instead of reusing existing ones (the frontend didn't recognise
/private/var/...as the same file it had open as/var/...). SoUrlIdis strictly for internal identity. Inconsole_annotate.rs, the rawUrlis kept for embedding in R code (#linedirectives, breakpoint calls) whileUrlIdis used only for HashMap lookups.The LSP only uses
UrlIdat the boundary where it notifies the console about document changes for breakpoint invalidation. Its own internal document state is still keyed by rawUrl. We might want to switch the LSP internals toUrlIdin the future if symlink mismatches become an issue there too, or simply for internal consistency.