From 8c0d58c86b999697592fdeebd2eecc66da28e742 Mon Sep 17 00:00:00 2001 From: temportalflux Date: Fri, 3 Jul 2026 16:11:12 -0400 Subject: [PATCH] collapse styling of conditions --- .../gpui_elements/src/editable_text/history.rs | 14 ++++++++------ crates/gpui_elements/src/editable_text/layout.rs | 16 ++++------------ 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/crates/gpui_elements/src/editable_text/history.rs b/crates/gpui_elements/src/editable_text/history.rs index 56bc2c772a..d7b97e59f4 100644 --- a/crates/gpui_elements/src/editable_text/history.rs +++ b/crates/gpui_elements/src/editable_text/history.rs @@ -66,12 +66,14 @@ impl EditableTextHistory { let now = Instant::now(); // Check if we should group with the last entry - if let Some(last) = self.undo_stack.last_mut() { - if now.duration_since(last.timestamp) < self.grouping_interval { - // Within group interval - extend the existing patch - if last.extend(&range, new_text_len) { - return; - } + if let Some(last) = self.undo_stack.last_mut() + && now.duration_since(last.timestamp) < self.grouping_interval + { + // The change was triggered within group interval timing. + // Try to extend the existing patch (which is a mutation). + // If extending successeds, then we can early-out. Otherwise the mutation is non-contiguous. + if last.extend(&range, new_text_len) { + return; } } diff --git a/crates/gpui_elements/src/editable_text/layout.rs b/crates/gpui_elements/src/editable_text/layout.rs index f4aa575be9..5c10046a26 100644 --- a/crates/gpui_elements/src/editable_text/layout.rs +++ b/crates/gpui_elements/src/editable_text/layout.rs @@ -55,18 +55,10 @@ impl TextLineSegment { return pos == self.text_range.start; } - // pos must be >= range-start - if pos < self.text_range.start { - return false; + if include_end { + (self.text_range.start..=self.text_range.end).contains(&pos) + } else { + self.text_range.contains(&pos) } - - // pos must be <= range-end - if pos > self.text_range.end { - return false; - } - - // pos must be < range-end - // or == is permitted if explicitly allowed (varies according to usage needs) - pos < self.text_range.end || include_end } }