From ccb9b5d27856204542c70475dcd0740ea27a3d24 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Tue, 22 Aug 2023 18:12:05 +0200 Subject: [PATCH] Query char_kind for completion triggers. Co-authored-by: Conrad Irwin --- crates/editor/src/multi_buffer.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/editor/src/multi_buffer.rs b/crates/editor/src/multi_buffer.rs index d4061f25dc6a22b8a3abd79ae0471c811e2b08e0..510f591655c9cc16a6f97af8a603d5039575c691 100644 --- a/crates/editor/src/multi_buffer.rs +++ b/crates/editor/src/multi_buffer.rs @@ -1346,9 +1346,7 @@ impl MultiBuffer { .map(|state| state.buffer.clone()) } - pub fn is_completion_trigger(&self, position: T, text: &str, cx: &AppContext) -> bool - where - T: ToOffset, + pub fn is_completion_trigger(&self, position: Anchor, text: &str, cx: &AppContext) -> bool { let mut chars = text.chars(); let char = if let Some(char) = chars.next() { @@ -1360,7 +1358,9 @@ impl MultiBuffer { return false; } - if char.is_alphanumeric() || char == '_' { + let language = self.language_at(position.clone(), cx); + + if char_kind(language.as_ref(), char) == CharKind::Word { return true; }