documents: undo in an untouched block steps the document; visual after preview opens an empty end
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
6f0401e967
commit
362a0fc9fa
4 files changed
+86
-8
No files matched your search
@@ -1,6 +1,6 @@
|
||||
use std::ops::Range;
|
||||
|
||||
use gpui::{AppContext as _, Context, Focusable as _, Window};
|
||||
use gpui::{App, AppContext as _, Context, Focusable as _, Window};
|
||||
|
||||
use super::{DocumentEvent, MarkdownDocument, Open};
|
||||
use crate::{
|
||||
@@ -31,6 +31,24 @@ impl MarkdownDocument {
|
||||
}
|
||||
}
|
||||
|
||||
/// 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()]
|
||||
})
|
||||
}
|
||||
|
||||
/// Undo or redo in the document's one history.
|
||||
pub(super) fn history(&mut self, redo: bool, window: &mut Window, cx: &mut Context<Self>) {
|
||||
self.commit(cx);
|
||||
self.editor.update(cx, |editor, cx| match redo {
|
||||
true => editor.redo(cx),
|
||||
false => editor.undo(cx),
|
||||
});
|
||||
window.focus(&self.focus, cx);
|
||||
self.focused(window, cx);
|
||||
}
|
||||
|
||||
/// Opens block `ix` as shown, or one past the end.
|
||||
pub(super) fn open(
|
||||
&mut self,
|
||||
|
||||
Reference in new issue
Block a user