From 059107605461e5380604b6bd2054160d4ca37932 Mon Sep 17 00:00:00 2001 From: "gcp-cherry-pick-bot[bot]" <98988430+gcp-cherry-pick-bot[bot]@users.noreply.github.com> Date: Tue, 10 Jun 2025 22:56:42 -0600 Subject: [PATCH] Don't push to selection history if selections are empty (cherry-pick #32433) (#32517) Cherry-picked Don't push to selection history if selections are empty (#32433) I got a panic during undo but haven't been able to repro it. Potentially a consequence of my changes in #31731 > Thread "main" panicked with "There must be at least one selection" at crates/editor/src/selections_collection.rs Leaving release notes blank as I'm not sure this actually fixes the panic Release Notes: - N/A Co-authored-by: Michael Sloan --- crates/editor/src/editor.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 13cac87731eb60cf582e48212054df6c2108d468..2413ff10c4f079710b1ec8f78ccc833faaf56fed 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -1226,6 +1226,13 @@ impl SelectionHistory { transaction_id: TransactionId, selections: Arc<[Selection]>, ) { + if selections.is_empty() { + log::error!( + "SelectionHistory::insert_transaction called with empty selections. Caller: {}", + std::panic::Location::caller() + ); + return; + } self.selections_by_transaction .insert(transaction_id, (selections, None)); }