documents: undo and redo leave a block only past its own history; typing lands after undo empties the document
CI / platforms (windows-latest) (push) Failing after 8s
CI / site (push) Successful in 21s
CI / crate (push) Failing after 11m46s
CI / platforms (ubuntu-24.04) (push) Canceled after 0s

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-12 04:28:33 -04:00
1 parent 362a0fc9fa
commit a3d9f089a3
5 files changed
+137 -87

No files matched your search

+9 -8
View File
@@ -23,19 +23,19 @@ fn moved(at: usize, edit: &Option<(Range<usize>, usize)>) -> Option<usize> {
}
impl MarkdownDocument {
/// An empty visual document takes typing at once.
/// An empty, read visual document takes typing at once.
pub(super) fn focused(&mut self, window: &mut Window, cx: &mut Context<Self>) {
let empty = self.editor.read(cx).text().trim().is_empty();
let empty = self.editor.read(cx).text().trim().is_empty() && self.read_now(cx);
if self.mode == MarkdownMode::Visual && self.open.is_none() && empty {
self.open(None, false, window, cx);
}
}
/// The open block still holds what it opened with.
pub(super) fn untouched(&self, cx: &App) -> bool {
self.open.as_ref().is_some_and(|open| {
open.input.read(cx).text() == &self.editor.read(cx).text()[open.range.clone()]
})
/// The open block has no step left that way.
pub(super) fn at_edge_of_history(&self, redo: bool, cx: &App) -> bool {
self.open
.as_ref()
.is_some_and(|open| !open.input.read(cx).can_step(redo))
}
/// Undo or redo in the document's one history.
@@ -46,7 +46,8 @@ impl MarkdownDocument {
false => editor.undo(cx),
});
window.focus(&self.focus, cx);
self.focused(window, cx);
// Once the change is read, an empty end opens.
cx.defer_in(window, |document, window, cx| document.focused(window, cx));
}
/// Opens block `ix` as shown, or one past the end.