Repository navigation
Percent-decode file URIs in language server path conversion - #1182
Open
Anatomydotexe wants to merge 1 commit into
Open
Anatomydotexe wants to merge 1 commit into
Anatomydotexe wants to merge 1 commit into
Conversation
This branch has not been deployed
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 #1122.
Problem
When run as a language server, StyLua resolved the configuration from the file's path taken straight from the document URI, without percent-decoding it (
to_file_pathinsrc/cli/lsp.rsusedself.path().as_str()). Editors such as VS Code percent-encode paths, so for a file whose path contains a space or a non-ASCII character, the.stylua.toml/.editorconfiglookup ran on a path that doesn't exist and the server fell back to default settings. The CLI formatted the same file differently. The decoding step from thels-typesreference implementation seems to have been dropped when it was ported in #1068.Change
to_file_pathnow percent-decodes the path throughfluent-uri, which is already used bylsp_types::Uri, before both the Unix and Windows branches. No new dependencies, and no other behavior changes.Tests
Three new tests in
src/cli/lsp.rs:.stylua.tomlstill takes precedence over.editorconfigthrough the LSPOn Linux,
cargo testpasses with default features, no default features, all features, and each syntax feature (luau, lua52, lua53, lua54, luajit, cfxlua).cargo fmt --checkandcargo clippy -D warningsalso pass. When the fix is reverted, exactly the 3 new tests fail.Limitations: the
cfg(windows)tests were only compiled forx86_64-pc-windows-gnu. They weren't run on Windows. Percent sequences that aren't valid UTF-8 decode lossily. I included a CHANGELOG entry and I'm happy to drop it.This change was prepared with AI coding agents and reviewed by me before submission.