diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2023-09-29 20:44:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-29 20:44:59 +0100 |
commit | 2d1af0cf51bac446f1c92e8a12db9b5052e37e12 (patch) | |
tree | 540375040f360a25937659c8c95bf0ed99810bec /cli/lsp/completions.rs | |
parent | 61b91e10ad41e6d207d60113a2f6f2b63a706940 (diff) |
feat(lsp): jupyter notebook analysis (#20719)
Diffstat (limited to 'cli/lsp/completions.rs')
-rw-r--r-- | cli/lsp/completions.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/cli/lsp/completions.rs b/cli/lsp/completions.rs index 94111fee8..c6fc6216e 100644 --- a/cli/lsp/completions.rs +++ b/cli/lsp/completions.rs @@ -2,6 +2,7 @@ use super::client::Client; use super::config::ConfigSnapshot; +use super::documents::cell_to_file_specifier; use super::documents::Documents; use super::documents::DocumentsFilter; use super::lsp_custom; @@ -364,11 +365,16 @@ fn get_local_completions( current: &str, range: &lsp::Range, ) -> Option<Vec<lsp::CompletionItem>> { + let base = match cell_to_file_specifier(base) { + Some(s) => s, + None => base.clone(), + }; + if base.scheme() != "file" { return None; } - let mut base_path = specifier_to_file_path(base).ok()?; + let mut base_path = specifier_to_file_path(&base).ok()?; base_path.pop(); let mut current_path = normalize_path(base_path.join(current)); // if the current text does not end in a `/` then we are still selecting on @@ -388,10 +394,10 @@ fn get_local_completions( let de = de.ok()?; let label = de.path().file_name()?.to_string_lossy().to_string(); let entry_specifier = resolve_path(de.path().to_str()?, &cwd).ok()?; - if &entry_specifier == base { + if entry_specifier == base { return None; } - let full_text = relative_specifier(base, &entry_specifier)?; + let full_text = relative_specifier(&base, &entry_specifier)?; // this weeds out situations where we are browsing in the parent, but // we want to filter out non-matches when the completion is manually // invoked by the user, but still allows for things like `../src/../` |