documents: a dropped block hands its focus to the document
CI / platforms (windows-latest) (push) Failing after 8s
CI / site (push) Successful in 21s
CI / crate (push) Failing after 12m5s
CI / platforms (ubuntu-24.04) (push) Canceled after 0s

An edit past an open block wrote it back and dropped its input while
it held focus, so focus fell to the window root and Undo reached
nothing. The next render passes such focus to the document.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-14 17:39:24 -04:00
1 parent 24ffc45c6b
commit 6c2d28c56e
7 files changed
+42 -4

No files matched your search

+5 -1
View File
@@ -97,6 +97,8 @@ pub struct MarkdownDocument {
editing: bool,
list: ListState,
open: Option<Open>,
/// A dropped block's focus, for the document to take.
orphan: Option<FocusHandle>,
/// A top line asked for, until the view holds it.
top: Option<Placement>,
asks: u64,
@@ -169,6 +171,7 @@ impl MarkdownDocument {
editing: false,
list: ListState::new(1, ListAlignment::Top, overdraw),
open: None,
orphan: None,
top: None,
asks: 0,
writes: 0,
@@ -344,7 +347,8 @@ impl MarkdownDocument {
/// Closes the open block without writing it.
fn drop_open(&mut self, cx: &mut Context<Self>) {
if self.open.take().is_some() {
if let Some(open) = self.open.take() {
self.orphan = Some(open.input.focus_handle(cx));
log::info!("markdown document: the open block closed unwritten");
cx.notify();
}