T21a round 2 fixes

- a field notes its selection when a key goes down, so undo of typing selects
  what the typing replaced
- reading order skips table cells merged away, so Up and Down across blocks
  land on cells that show
This commit is contained in:
ZacharyZhang-NY committed 2026-09-26 03:57:27 -04:00
1 parent f3e2c6c27f
commit 187f54253e
6 files changed
+68 -3

No files matched your search

+13 -1
View File
@@ -162,14 +162,26 @@ impl BlockEditor {
/// Records what changed as one undo step, a burst of typing as one, and tells the owner.
pub(super) fn settle(&mut self, typing: bool, cx: &mut Context<Self>) {
let now = self.snapshot(cx);
let typed_from = self.typed_from.take();
if now.blocks != self.current.blocks {
let before = std::mem::replace(&mut self.current, now);
let mut before = std::mem::replace(&mut self.current, now);
if typed_from.is_some() {
before.caret = typed_from;
}
self.history.record(before, typing);
cx.emit(BlockEvent::Changed);
cx.notify();
}
}
/// Where a key went down, before the field acts on it: the start a typing burst's undo goes back to.
pub(crate) fn note_key(&mut self, key: u64, field: usize, cx: &Context<Self>) {
let selection = self.blocks[self.index(key)].fields[field]
.read(cx)
.selection();
self.typed_from = Some((key, field, selection));
}
/// Records the document before a change to its blocks.
pub(crate) fn before_change(&mut self, cx: &mut Context<Self>) {
self.settle(true, cx);