collapse styling of conditions
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user