summaryrefslogtreecommitdiff
path: root/cli/lsp/registries.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/lsp/registries.rs')
-rw-r--r--cli/lsp/registries.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/cli/lsp/registries.rs b/cli/lsp/registries.rs
index 9b68b8850..acb6a401a 100644
--- a/cli/lsp/registries.rs
+++ b/cli/lsp/registries.rs
@@ -651,12 +651,17 @@ impl ModuleRegistry {
is_incomplete = true;
}
for (idx, item) in items.into_iter().enumerate() {
- let label = if let Some(p) = &prefix {
+ let mut label = if let Some(p) = &prefix {
format!("{}{}", p, item)
} else {
item.clone()
};
- let kind = if key.name == last_key_name {
+ if label.ends_with('/') {
+ label.pop();
+ }
+ let kind = if key.name == last_key_name
+ && !item.ends_with('/')
+ {
Some(lsp::CompletionItemKind::FILE)
} else {
Some(lsp::CompletionItemKind::FOLDER)
@@ -666,8 +671,11 @@ impl ModuleRegistry {
key.name.clone(),
StringOrVec::from_str(&item, &key),
);
- let path =
+ let mut path =
compiler.to_path(&params).unwrap_or_default();
+ if path.ends_with('/') {
+ path.pop();
+ }
let item_specifier = base.join(&path).ok()?;
let full_text = item_specifier.as_str();
let text_edit = Some(lsp::CompletionTextEdit::Edit(
@@ -677,6 +685,7 @@ impl ModuleRegistry {
},
));
let command = if key.name == last_key_name
+ && !item.ends_with('/')
&& !specifier_exists(&item_specifier)
{
Some(lsp::Command {