Skip to content

Commit

Permalink
fix insertion
Browse files Browse the repository at this point in the history
  • Loading branch information
Markos-Th09 committed Oct 31, 2023
1 parent 951a10b commit 909f975
Showing 1 changed file with 19 additions and 25 deletions.
44 changes: 19 additions & 25 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,35 +505,29 @@ pub fn get_completions_for_prefix(mut prefix: &str) -> (usize, Vec<Completion>)
prepend = a;
prefix = b;
}

if let Some(letter) = prefix.strip_prefix('\\') {
let position = prepend.len() + prepend.len().min(1);
if letter.starts_with(|c: char| !c.is_ascii_alphabetic()) {
return (0, vec![]);
} else if letter.starts_with(|c: char| c.is_ascii_uppercase()) {
return GREEK_UPPERCASE_LETTERS
.iter()
.find(|l| l.0 == letter)
.map_or((0, vec![]), |l| {
(
0,
vec![Completion {
display: prefix.to_string(),
insert: l.1.to_string(),
}],
)
});
}
return GREEK_LOWERCASE_LETTERS
.iter()
.find(|l| l.0 == letter)
.map_or((0, vec![]), |l| {
(
0,
vec![Completion {
display: prefix.to_string(),
insert: l.1.to_string(),
}],
)
});

return if letter.starts_with(|c: char| c.is_ascii_uppercase()) {
GREEK_UPPERCASE_LETTERS
} else {
GREEK_LOWERCASE_LETTERS
}
.iter()
.find(|l| l.0 == letter)
.map_or((0, vec![]), |l| {
(
position,
vec![Completion {
display: prefix.to_string(),
insert: l.1.to_string(),
}],
)
});
}
if prefix.is_empty() {
return (0, vec![]);
Expand Down

0 comments on commit 909f975

Please sign in to comment.