mirror of https://github.com/helix-editor/helix
When an LSP server (e.g., pyright) returns a URI for a file that was originally opened via a symlink, it often returns the resolved, canonical URI. Previously, Helix's conversion from this `file://` URI to an internal `helix-core::Uri` used a normalization function that did not fully resolve symlinks. This could lead to a mismatch: 1. You open `/symlink/file.py`. Helix stores its path, canonicalized to `/real/path/to/file.py`. 2. LSP "go to definition" returns URI for `/real/path/to/file.py`. 3. Helix converts this URI. If this conversion doesn't also result in the exact same canonical form as in step 1 (due to not resolving the symlink part if the LSP URI was subtly different but still pointed canonically to the same file, or if the internal URI representation wasn't consistently canonical), Helix might not find the existing document. 4. This would result in Helix opening the same file content in a new tab, treating it as a distinct file. This change modifies `helix-core/src/uri.rs` to use `helix_stdx::path::canonicalize` when converting `file://` URLs to `helix-core::Uri::File`. This ensures that the path stored in the `Uri` is the fully resolved, canonical path. Combined with `Document::set_path` already storing canonical paths for documents, this change ensures that URIs from LSPs and internal document URIs are both in a consistent, canonical form, allowing Helix to correctly identify and reuse existing buffers for symlinked files. I attempted to add an integration test, but I was hindered by compilation timeouts in the testing environment. |
||
---|---|---|
.. | ||
src | ||
tests | ||
.gitignore | ||
Cargo.toml |