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:
Bennet Bo Fenner
2024-03-11 09:08:18 -06:00
committed by GitHub
parent eb5e18c66d
commit a8fa1f7363
6 changed files with 101 additions and 9 deletions
+25 -6
View File
@@ -5206,20 +5206,39 @@ async fn test_auto_replace_emoji_shortcode(cx: &mut gpui::TestAppContext) {
editor.handle_input(":", cx);
assert_eq!(editor.text(cx), "Hello 👋 😄".unindent());
editor.handle_input(":1:", cx);
assert_eq!(editor.text(cx), "Hello 👋 😄:1:".unindent());
// Ensure shortcode gets replaced when it is part of a word that only consists of emojis
editor.handle_input(":wave", cx);
assert_eq!(editor.text(cx), "Hello 👋 😄:wave".unindent());
editor.handle_input(":", cx);
assert_eq!(editor.text(cx), "Hello 👋 😄👋".unindent());
editor.handle_input(":1", cx);
assert_eq!(editor.text(cx), "Hello 👋 😄👋:1".unindent());
editor.handle_input(":", cx);
assert_eq!(editor.text(cx), "Hello 👋 😄👋:1:".unindent());
// Ensure shortcode does not get replaced when it is part of a word
editor.handle_input(" Test:wave:", cx);
assert_eq!(editor.text(cx), "Hello 👋 😄:1: Test:wave:".unindent());
editor.handle_input(" Test:wave", cx);
assert_eq!(editor.text(cx), "Hello 👋 😄👋:1: Test:wave".unindent());
editor.handle_input(":", cx);
assert_eq!(editor.text(cx), "Hello 👋 😄👋:1: Test:wave:".unindent());
editor.set_auto_replace_emoji_shortcode(false);
// Ensure shortcode does not get replaced when auto replace is off
editor.handle_input(" :wave:", cx);
editor.handle_input(" :wave", cx);
assert_eq!(
editor.text(cx),
"Hello 👋 😄:1: Test:wave: :wave:".unindent()
"Hello 👋 😄👋:1: Test:wave: :wave".unindent()
);
editor.handle_input(":", cx);
assert_eq!(
editor.text(cx),
"Hello 👋 😄👋:1: Test:wave: :wave:".unindent()
);
});
}