From 1ec91a873888318c30a4391958220f6f702d121c Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 3 Feb 2025 23:42:13 +0200 Subject: [PATCH] Clip points when searching for `@` in the Assistant 2 panel (#24147) Release Notes: - N/A --- crates/assistant2/src/message_editor.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/assistant2/src/message_editor.rs b/crates/assistant2/src/message_editor.rs index 70d32f3dda53a989c3a4daf7c2da2af6caf619c8..82f4907372ede91dfde71dce15b5bb806026f337 100644 --- a/crates/assistant2/src/message_editor.rs +++ b/crates/assistant2/src/message_editor.rs @@ -12,6 +12,7 @@ use language_model_selector::LanguageModelSelector; use rope::Point; use settings::Settings; use std::time::Duration; +use text::Bias; use theme::ThemeSettings; use ui::{ prelude::*, ButtonLike, KeyBinding, PopoverMenu, PopoverMenuHandle, Switch, TintColor, Tooltip, @@ -239,7 +240,10 @@ impl MessageEditor { let snapshot = editor.buffer().read(cx).snapshot(cx); let newest_cursor = editor.selections.newest::(cx).head(); if newest_cursor.column > 0 { - let behind_cursor = Point::new(newest_cursor.row, newest_cursor.column - 1); + let behind_cursor = snapshot.clip_point( + Point::new(newest_cursor.row, newest_cursor.column - 1), + Bias::Left, + ); let char_behind_cursor = snapshot.chars_at(behind_cursor).next(); if char_behind_cursor == Some('@') { self.inline_context_picker_menu_handle.show(window, cx);