helix/helix-core
google-labs-jules[bot] 728975aa08 Fix: Ensure canonical paths for LSP URI conversion to prevent duplicate tabs
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.
2025-05-21 01:42:33 +00:00
..
src Fix: Ensure canonical paths for LSP URI conversion to prevent duplicate tabs 2025-05-21 01:42:33 +00:00
tests Replace tree-sitter with tree-house 2025-05-13 18:43:43 -04:00
.gitignore Initial import. 2020-05-20 18:14:51 +09:00
Cargo.toml Replace tree-sitter with tree-house 2025-05-13 18:43:43 -04:00