[Repo Assist] fix: encode non-ASCII path chars as UTF-8 percent sequences in FilePathToUri#1455
Merged
Krzysztof-Cieslak merged 1 commit intomainfrom Feb 23, 2026
Conversation
Characters in the U+0080..U+00FF range (e.g. accented letters like ó) were encoded as a single-byte `%XX` using their Unicode code point, rather than their UTF-8 byte sequence. For example, ó (U+00F3) was emitted as `%F3` instead of the correct `%C3%B3`. The LSP URI spec requires percent-encoded bytes to be UTF-8. When a client or .NET's own Uri.LocalPath property receives `%F3`, it tries to decode it as a standalone UTF-8 byte (invalid — 0xF3 starts a 4-byte sequence but nothing follows) and either leaves it encoded or substitutes a replacement character, breaking go-to-definition and diagnostics for projects in directories whose names contain accented/non-ASCII characters. Fix: change the else branch in FilePathToUri to obtain the UTF-8 byte representation of the character (via Encoding.UTF8.GetBytes) and emit one `%XX` segment per byte. ASCII special chars (e.g. space => `%20`) are unaffected because their single-byte UTF-8 encoding is identical to their code point. Adds a new unit test that asserts ó is encoded as `%C3%B3`, and adds a roundtrip sample for a unicode-containing path to the existing suite. Closes #840 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
✅ Pull request created: #1455 |
17 tasks
github-actions bot
pushed a commit
that referenced
this pull request
Feb 23, 2026
Summarise changes merged since v0.83.0: - Fix SourceLink go-to-def on .NET 10 Linux (#1441) - Add backgroundServiceProgress config option (#1452) - Fix { trigger char for interpolated strings (#1454) - Fix non-ASCII URI encoding (#1455) - Fix spurious get/set rename (#1453) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
github-actions bot
added a commit
that referenced
this pull request
Feb 24, 2026
Include all PRs merged since v0.83.0: - #1441: Fix SourceLink go-to-def failure on .NET 10 on Linux - #1452: Add FSharp.notifications.backgroundServiceProgress config option - #1449: Fix semantic token multiline range uint32 underflow - #1453: Fix spurious get/set rename in TextDocumentRename - #1454: Fix missing { interpolated string completion trigger - #1455: Fix non-ASCII path encoding in file URIs - #1456: Disable inline values by default to restore pipeline hints - #1457: Fix missing parens in function-type segments in AddExplicitTypeAnnotation - #1458: Fix signature help parameter types showing fully-qualified names - #1463: Fix seealso href/langword XML doc rendering Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Closes #840
Root Cause
FilePathToUriinUtils.fswas encoding non-ASCII characters in the U+0080–U+00FF range (accented letters, e.g.óincódigo) as a single-byte%XXvalue derived from the Unicode code point. Foró(U+00F3) this produced%F3.However, the LSP URI specification (and RFC 3986) require percent-encoded bytes to use UTF-8. In UTF-8,
óis two bytes —0xC3 0xB3— so the correct encoding is%C3%B3.When a client (or .NET's own
Uri.LocalPath) receives%F3, it interprets it as a standalone byte that starts an incomplete 4-byte UTF-8 sequence. The path is left asc%F3digorather thancódigo, breaking go-to-definition, diagnostics, and file-open for any project living in a directory whose name contains such characters.Fix
Changed the
elsebranch inFilePathToUrito obtain the UTF-8 byte representation of each character viaText.Encoding.UTF8.GetBytesand emit one%XXsegment per byte:ASCII characters (space →
%20,#→%23, etc.) are unaffected because their single-byte UTF-8 encoding equals their code point. Characters above U+00FF (ideographs, etc.) already passed through unencoded and are unchanged.Trade-offs
GetBytes(string c)for non-ASCII chars). These paths are encoded rarely (once per opened document), so the cost is negligible.Test Status
dotnet build src/FsAutoComplete.Core -f net8.0— 0 errors, 0 warnings--filter "Uri tests") including the new test:FilePathToUri encodes accented chars as UTF-8 percent sequences— verifiesó→%C3%B3