Skip to content

Commit 2340636

Browse files
committed
completion: fix 空格补全
1 parent eeaaf1e commit 2340636

File tree

1 file changed

+11
-10
lines changed
  • crates/emmylua_ls/src/handlers/completion/providers

1 file changed

+11
-10
lines changed

crates/emmylua_ls/src/handlers/completion/providers/mod.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@ use rowan::TextRange;
1818
use super::completion_builder::CompletionBuilder;
1919

2020
pub fn add_completions(builder: &mut CompletionBuilder) -> Option<()> {
21-
if is_space_completion_in_call_arg_list(builder).is_some() {
22-
type_special_provider::add_completion(builder);
23-
return Some(());
21+
// 空格补全只允许位于函数调用参数列表时非主动触发
22+
if is_space_completion(builder).is_some() {
23+
match LuaAst::cast(builder.trigger_token.parent()?)? {
24+
LuaAst::LuaCallArgList(_) => {
25+
type_special_provider::add_completion(builder);
26+
return Some(());
27+
}
28+
_ => return Some(()),
29+
}
2430
}
2531

2632
postfix_provider::add_completion(builder);
@@ -52,16 +58,11 @@ pub fn add_completions(builder: &mut CompletionBuilder) -> Option<()> {
5258
Some(())
5359
}
5460

55-
// 空格补全只允许位于函数调用参数列表时非主动触发
56-
fn is_space_completion_in_call_arg_list(builder: &CompletionBuilder) -> Option<()> {
61+
fn is_space_completion(builder: &CompletionBuilder) -> Option<()> {
5762
if builder.get_trigger_text().is_empty()
5863
&& builder.trigger_kind == CompletionTriggerKind::TRIGGER_CHARACTER
5964
{
60-
let node = LuaAst::cast(builder.trigger_token.parent()?)?;
61-
match node {
62-
LuaAst::LuaCallArgList(_) => Some(()),
63-
_ => None,
64-
}
65+
Some(())
6566
} else {
6667
None
6768
}

0 commit comments

Comments
 (0)