From 120e532e97502fee2cdf74751af7d151bf6b7e97 Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Sun, 18 May 2025 16:09:32 +0200 Subject: [PATCH] Fix undoing a deletion not restoring the selection (#15) `edit_begin` copies the current selection into the undo record. This means we must delay `set_selection` until after the edit. --- src/buffer/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/buffer/mod.rs b/src/buffer/mod.rs index 8521285..5587cae 100644 --- a/src/buffer/mod.rs +++ b/src/buffer/mod.rs @@ -1911,7 +1911,6 @@ impl TextBuffer { if let Some(r) = self.selection_range_internal(false) { (beg, end) = r; - self.set_selection(None); } else { if (delta == -1 && self.cursor.offset == 0) || (delta == 1 && self.cursor.offset >= self.text_length()) @@ -1933,6 +1932,8 @@ impl TextBuffer { self.edit_begin(HistoryType::Delete, beg); self.edit_delete(end); self.edit_end(); + + self.set_selection(None); } /// Returns the logical position of the first character on this line.