agent_ui: Fix panic in message editor (#44493)

Release Notes:

- N/A
This commit is contained in:
Bennet Bo Fenner
2025-12-09 18:55:29 +00:00
committed by GitHub
parent 04d920016f
commit bfab0b71e0
+9 -2
View File
@@ -567,6 +567,14 @@ impl MessageEditor {
{
cx.stop_propagation();
let insertion_target = self
.editor
.read(cx)
.selections
.newest_anchor()
.start
.text_anchor;
let project = workspace.read(cx).project().clone();
for selection in selections {
if let (Some(file_path), Some(line_range)) =
@@ -587,8 +595,7 @@ impl MessageEditor {
let snapshot = buffer.snapshot(cx);
let (excerpt_id, _, buffer_snapshot) =
snapshot.as_singleton().unwrap();
let start_offset = buffer_snapshot.len();
let text_anchor = buffer_snapshot.anchor_before(start_offset);
let text_anchor = insertion_target.bias_left(&buffer_snapshot);
editor.insert(&mention_text, window, cx);
editor.insert(" ", window, cx);