summaryrefslogtreecommitdiff
path: root/cli/lsp/tsc.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/lsp/tsc.rs')
-rw-r--r--cli/lsp/tsc.rs45
1 files changed, 42 insertions, 3 deletions
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs
index 4eb425c1f..691f7c91d 100644
--- a/cli/lsp/tsc.rs
+++ b/cli/lsp/tsc.rs
@@ -31,6 +31,7 @@ use crate::tsc;
use crate::tsc::ResolveArgs;
use crate::util::path::relative_specifier;
use crate::util::path::specifier_to_file_path;
+use crate::util::path::to_percent_decoded_str;
use dashmap::DashMap;
use deno_ast::MediaType;
@@ -543,6 +544,10 @@ impl TsServer {
.and_then(|mut changes| {
for changes in &mut changes {
changes.normalize(&self.specifier_map)?;
+ for text_changes in &mut changes.text_changes {
+ text_changes.new_text =
+ to_percent_decoded_str(&text_changes.new_text);
+ }
}
Ok(changes)
})
@@ -1611,7 +1616,41 @@ fn display_parts_to_string(
link.name = Some(part.text.clone());
}
}
- _ => out.push(part.text.clone()),
+ _ => out.push(
+ // should decode percent-encoding string when hovering over the right edge of module specifier like below
+ // module "file:///path/to/🦕"
+ to_percent_decoded_str(&part.text),
+ // NOTE: The reason why an example above that lacks `.ts` extension is caused by the implementation of tsc itself.
+ // The request `tsc.request.getQuickInfoAtPosition` receives the payload from tsc host as follows.
+ // {
+ // text_span: {
+ // start: 19,
+ // length: 9,
+ // },
+ // displayParts:
+ // [
+ // {
+ // text: "module",
+ // kind: "keyword",
+ // target: null,
+ // },
+ // {
+ // text: " ",
+ // kind: "space",
+ // target: null,
+ // },
+ // {
+ // text: "\"file:///path/to/%F0%9F%A6%95\"",
+ // kind: "stringLiteral",
+ // target: null,
+ // },
+ // ],
+ // documentation: [],
+ // tags: null,
+ // }
+ //
+ // related issue: https://github.com/denoland/deno/issues/16058
+ ),
}
}
@@ -5424,7 +5463,7 @@ mod tests {
.get_edits_for_file_rename(
snapshot,
resolve_url("file:///b.ts").unwrap(),
- resolve_url("file:///c.ts").unwrap(),
+ resolve_url("file:///🦕.ts").unwrap(),
FormatCodeSettings::default(),
UserPreferences::default(),
)
@@ -5439,7 +5478,7 @@ mod tests {
start: 8,
length: 6,
},
- new_text: "./c.ts".to_string(),
+ new_text: "./🦕.ts".to_string(),
}],
is_new_file: None,
}]