fix(lsp): decoding percent-encoding(non-ASCII) file path correctly (#22582)

This commit is contained in:
Hajime-san 2024-03-28 00:58:18 +09:00 committed by GitHub
parent 3462248571
commit feb744cebd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 162 additions and 19 deletions

View file

@ -122,6 +122,7 @@ use crate::tools::upgrade::upgrade_check_enabled;
use crate::util::fs::remove_dir_all_if_exists;
use crate::util::path::is_importable_ext;
use crate::util::path::specifier_to_file_path;
use crate::util::path::to_percent_decoded_str;
use crate::util::progress_bar::ProgressBar;
use crate::util::progress_bar::ProgressBarStyle;
@ -1738,16 +1739,21 @@ impl Inner {
match resolution {
Resolution::Ok(resolved) => {
let specifier = &resolved.specifier;
let format = |scheme: &str, rest: &str| -> String {
format!("{}​{}", scheme, rest).replace('@', "​@")
};
match specifier.scheme() {
"data" => "_(a data url)_".to_string(),
"blob" => "_(a blob url)_".to_string(),
"file" => format(
&specifier[..url::Position::AfterScheme],
&to_percent_decoded_str(&specifier[url::Position::AfterScheme..]),
),
_ => {
let mut result = format!(
"{}​{}",
let mut result = format(
&specifier[..url::Position::AfterScheme],
&specifier[url::Position::AfterScheme..],
)
.replace('@', "​@");
);
if let Ok(jsr_req_ref) =
JsrPackageReqReference::from_specifier(specifier)
{