Fix import completions
This commit is contained in:
parent
616dec8f03
commit
5879dcfd4c
|
@ -387,8 +387,9 @@ impl Server {
|
||||||
|
|
||||||
match found {
|
match found {
|
||||||
// TODO: test
|
// TODO: test
|
||||||
None | Some(Located::Definition(Definition::Use(Use { .. }))) => {
|
None => self.completion_for_import(&[]),
|
||||||
self.completion_for_import()
|
Some(Located::Definition(Definition::Use(Use { module, .. }))) => {
|
||||||
|
self.completion_for_import(module)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: autocompletion for patterns
|
// TODO: autocompletion for patterns
|
||||||
|
@ -408,7 +409,7 @@ impl Server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn completion_for_import(&self) -> Option<Vec<lsp_types::CompletionItem>> {
|
fn completion_for_import(&self, module: &[String]) -> Option<Vec<lsp_types::CompletionItem>> {
|
||||||
let compiler = self.compiler.as_ref()?;
|
let compiler = self.compiler.as_ref()?;
|
||||||
|
|
||||||
// TODO: Test
|
// TODO: Test
|
||||||
|
@ -421,6 +422,7 @@ impl Server {
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.chain(project_modules)
|
.chain(project_modules)
|
||||||
.sorted()
|
.sorted()
|
||||||
|
.filter(|m| m.starts_with(&module.join("/")))
|
||||||
.map(|label| lsp_types::CompletionItem {
|
.map(|label| lsp_types::CompletionItem {
|
||||||
label,
|
label,
|
||||||
kind: None,
|
kind: None,
|
||||||
|
|
Loading…
Reference in New Issue