summaryrefslogtreecommitdiff
path: root/cli/lsp/completions.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/lsp/completions.rs')
-rw-r--r--cli/lsp/completions.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/cli/lsp/completions.rs b/cli/lsp/completions.rs
index 601ebb52b..07857fb48 100644
--- a/cli/lsp/completions.rs
+++ b/cli/lsp/completions.rs
@@ -114,9 +114,8 @@ pub(crate) async fn get_import_completions(
state_snapshot: &language_server::StateSnapshot,
client: lspower::Client,
) -> Option<lsp::CompletionResponse> {
- let (text, _, range) = state_snapshot
- .documents
- .get_maybe_dependency(specifier, position)?;
+ let document = state_snapshot.documents.get(specifier)?;
+ let (text, _, range) = document.get_maybe_dependency(position)?;
let range = to_narrow_lsp_range(&range);
// completions for local relative modules
if text.starts_with("./") || text.starts_with("../") {
@@ -134,7 +133,9 @@ pub(crate) async fn get_import_completions(
};
let maybe_items = state_snapshot
.module_registries
- .get_completions(&text, offset, &range, state_snapshot)
+ .get_completions(&text, offset, &range, |specifier| {
+ state_snapshot.documents.contains_specifier(specifier)
+ })
.await;
let items = maybe_items.unwrap_or_else(|| {
get_workspace_completions(specifier, &text, &range, state_snapshot)
@@ -276,7 +277,12 @@ fn get_workspace_completions(
range: &lsp::Range,
state_snapshot: &language_server::StateSnapshot,
) -> Vec<lsp::CompletionItem> {
- let workspace_specifiers = state_snapshot.documents.specifiers(false, true);
+ let workspace_specifiers = state_snapshot
+ .documents
+ .documents(false, true)
+ .into_iter()
+ .map(|d| d.specifier().clone())
+ .collect();
let specifier_strings =
get_relative_specifiers(specifier, workspace_specifiers);
specifier_strings
@@ -449,7 +455,7 @@ mod tests {
.set(&specifier, HashMap::default(), source.as_bytes())
.expect("could not cache file");
assert!(
- documents.content(&specifier).is_some(),
+ documents.get(&specifier).is_some(),
"source could not be setup"
);
}