Skip to content

Commit

Permalink
Clip points when searching for @ in the Assistant 2 panel (#24147)
Browse files Browse the repository at this point in the history
Release Notes:

- N/A
  • Loading branch information
SomeoneToIgnore authored Feb 3, 2025
1 parent 11e095b commit 1ec91a8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/assistant2/src/message_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -239,7 +240,10 @@ impl MessageEditor {
let snapshot = editor.buffer().read(cx).snapshot(cx);
let newest_cursor = editor.selections.newest::<Point>(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);
Expand Down

0 comments on commit 1ec91a8

Please sign in to comment.