mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
parent
d0dd838521
commit
9c7ed1c98b
1 changed files with 32 additions and 1 deletions
|
@ -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)
|
||||
}
|
||||
|
@ -3673,6 +3679,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 {
|
||||
|
|
Loading…
Reference in a new issue