chat: fix emoji completions when word consists of emojis (#9107)
https://github.com/zed-industries/zed/assets/53836821/f4b31c47-d306-43f5-b971-0969f64a48f9 Fix for #9096 @JosephTLyons Release Notes: - Fixed emoji completion not showing up when word contains only emojis (#9096)
This commit is contained in:
@@ -2653,10 +2653,31 @@ impl Editor {
|
||||
let mut found_colon = false;
|
||||
for char in snapshot.reversed_chars_at(position).take(100) {
|
||||
// Found a possible emoji shortcode in the middle of the buffer
|
||||
if found_colon && char.is_whitespace() {
|
||||
chars.reverse();
|
||||
return Some(chars.iter().collect());
|
||||
if found_colon {
|
||||
if char.is_whitespace() {
|
||||
chars.reverse();
|
||||
return Some(chars.iter().collect());
|
||||
}
|
||||
// If the previous character is not a whitespace, we are in the middle of a word
|
||||
// and we only want to complete the shortcode if the word is made up of other emojis
|
||||
let mut containing_word = String::new();
|
||||
for ch in snapshot
|
||||
.reversed_chars_at(position)
|
||||
.skip(chars.len() + 1)
|
||||
.take(100)
|
||||
{
|
||||
if ch.is_whitespace() {
|
||||
break;
|
||||
}
|
||||
containing_word.push(ch);
|
||||
}
|
||||
let containing_word = containing_word.chars().rev().collect::<String>();
|
||||
if util::word_consists_of_emojis(containing_word.as_str()) {
|
||||
chars.reverse();
|
||||
return Some(chars.iter().collect());
|
||||
}
|
||||
}
|
||||
|
||||
if char.is_whitespace() || !char.is_ascii() {
|
||||
return None;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user