documents: reset keeps the caret and the top line
CI / platforms (windows-latest) (push) Failing after 8s
CI / site (push) Successful in 21s
CI / crate (push) Failing after 11m55s
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 07:48:16 -04:00
1 parent d126a7e7f7
commit e89fb32f43
2 files changed
+29 -1

No files matched your search

+11 -1
View File
@@ -206,10 +206,20 @@ impl MarkdownDocument {
.update(cx, |editor, cx| editor.set_text(text, cx));
}
/// Replaces the text, undo afresh; open typing drops.
/// New text, undo afresh; caret and top line stay.
pub fn reset(&mut self, text: impl Into<String>, cx: &mut Context<Self>) {
let ((line, column), top) = (self.caret(cx), self.top_line(cx));
self.drop_open(cx);
self.editor.update(cx, |editor, cx| editor.reset(text, cx));
self.set_caret(line, column, cx);
// Placed once the new text is read.
self.asks += 1;
self.top = Some(Placement {
line: top,
ask: self.asks,
placing: false,
});
cx.notify();
}
/// The headings as last read, with lines from zero.