acp: Cancel editing when focus is lost and message was not changed (#36822)
Release Notes: - N/A
This commit is contained in:
parent
54c7d9dc5f
commit
d8bffd7ef2
3 changed files with 24 additions and 7 deletions
|
@ -762,6 +762,7 @@ impl AcpThreadView {
|
|||
MessageEditorEvent::Focus => {
|
||||
self.cancel_editing(&Default::default(), window, cx);
|
||||
}
|
||||
MessageEditorEvent::LostFocus => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -793,6 +794,18 @@ impl AcpThreadView {
|
|||
cx.notify();
|
||||
}
|
||||
}
|
||||
ViewEvent::MessageEditorEvent(editor, MessageEditorEvent::LostFocus) => {
|
||||
if let Some(thread) = self.thread()
|
||||
&& let Some(AgentThreadEntry::UserMessage(user_message)) =
|
||||
thread.read(cx).entries().get(event.entry_index)
|
||||
&& user_message.id.is_some()
|
||||
{
|
||||
if editor.read(cx).text(cx).as_str() == user_message.content.to_markdown(cx) {
|
||||
self.editing_message = None;
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
ViewEvent::MessageEditorEvent(editor, MessageEditorEvent::Send) => {
|
||||
self.regenerate(event.entry_index, editor, window, cx);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue