Skip to content

Commit f7409e2

Browse files
committed
update check_match_word
1 parent a733ae4 commit f7409e2

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

crates/emmylua_ls/src/handlers/completion/add_completions/check_match_word.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::collections::HashSet;
2+
13
pub fn check_match_word(key: &str, candidate_key: &str) -> bool {
24
if key.is_empty() {
35
return true; // 关键词为空, 一般是在空白处主动触发补全
@@ -30,6 +32,14 @@ pub fn check_match_word(key: &str, candidate_key: &str) -> bool {
3032
if is_word_start {
3133
let curr_lowercase = curr_char.to_lowercase().next().unwrap();
3234
if curr_lowercase == key_first_char {
35+
// 如果首字母匹配, 则需要检查 candidate_key 是否包含 key 中的所有字符
36+
let candidate_key_set: HashSet<char> =
37+
candidate_key.to_lowercase().chars().collect();
38+
for trigger_char in key.to_lowercase().chars() {
39+
if !candidate_key_set.contains(&trigger_char) {
40+
return false;
41+
}
42+
}
3343
return true;
3444
}
3545
}

0 commit comments

Comments
 (0)