summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/lsp/tsc.rs33
1 files changed, 32 insertions, 1 deletions
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs
index 28a3e7583..71606a05b 100644
--- a/cli/lsp/tsc.rs
+++ b/cli/lsp/tsc.rs
@@ -2396,7 +2396,13 @@ fn op_exists(state: &mut State, args: SpecifierArgs) -> Result<bool, AnyError> {
// forrest for the trees as well as it compounds any lsp performance
// challenges, opening a single document in the editor causes some 3k worth
// of op_exists requests... :omg:
- let specifier = state.normalize_specifier(args.specifier)?;
+ let specifier = match state.normalize_specifier(&args.specifier) {
+ Ok(url) => url,
+ // sometimes tsc tries to query invalid specifiers, especially when
+ // something else isn't quite right, so instead of bubbling up the error
+ // back to tsc, we simply swallow it and say the file doesn't exist
+ Err(err) => return Ok(false),
+ };
let result = state.state_snapshot.documents.exists(&specifier);
Ok(result)
}
@@ -3674,6 +3680,31 @@ mod tests {
}
#[test]
+ fn test_op_exists() {
+ let (_, state_snapshot, _) = setup(
+ false,
+ json!({
+ "target": "esnext",
+ "module": "esnext",
+ "lib": ["deno.ns", "deno.window"],
+ "noEmit": true,
+ }),
+ &[],
+ );
+ let performance = Arc::new(Performance::default());
+ let mut state = State::new(state_snapshot, performance);
+ let actual = op_exists(
+ &mut state,
+ SpecifierArgs {
+ specifier: "/error/unknown:something/index.d.ts".to_string(),
+ },
+ );
+ assert!(actual.is_ok());
+ let actual = actual.unwrap();
+ assert!(!actual);
+ }
+
+ #[test]
fn test_completion_entry_filter_text() {
let fixture = CompletionEntry {
kind: ScriptElementKind::MemberVariableElement,