Remove result from anchor cmp functions
Co-authored-by: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
ab631cf6c3
commit
92c7b5d6ef
11 changed files with 68 additions and 141 deletions
|
@ -2545,7 +2545,7 @@ impl Editor {
|
|||
.range
|
||||
.end
|
||||
.min(&excerpt_range.end, cursor_buffer_snapshot);
|
||||
if start.cmp(&end, cursor_buffer_snapshot).unwrap().is_ge() {
|
||||
if start.cmp(&end, cursor_buffer_snapshot).is_ge() {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2672,8 +2672,7 @@ impl Editor {
|
|||
})
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
tabstop_ranges
|
||||
.sort_unstable_by(|a, b| a.start.cmp(&b.start, snapshot).unwrap());
|
||||
tabstop_ranges.sort_unstable_by(|a, b| a.start.cmp(&b.start, snapshot));
|
||||
tabstop_ranges
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
|
@ -4700,13 +4699,13 @@ impl Editor {
|
|||
|
||||
let start_ix = match self
|
||||
.selections
|
||||
.binary_search_by(|probe| probe.end.cmp(&range.start, &buffer).unwrap())
|
||||
.binary_search_by(|probe| probe.end.cmp(&range.start, &buffer))
|
||||
{
|
||||
Ok(ix) | Err(ix) => ix,
|
||||
};
|
||||
let end_ix = match self
|
||||
.selections
|
||||
.binary_search_by(|probe| probe.start.cmp(&range.end, &buffer).unwrap())
|
||||
.binary_search_by(|probe| probe.start.cmp(&range.end, &buffer))
|
||||
{
|
||||
Ok(ix) => ix + 1,
|
||||
Err(ix) => ix,
|
||||
|
@ -4928,8 +4927,7 @@ impl Editor {
|
|||
selections.sort_by(|a, b| {
|
||||
a.start
|
||||
.cmp(&b.start, &*buffer)
|
||||
.unwrap()
|
||||
.then_with(|| b.end.cmp(&a.end, &*buffer).unwrap())
|
||||
.then_with(|| b.end.cmp(&a.end, &*buffer))
|
||||
});
|
||||
|
||||
// Merge overlapping selections
|
||||
|
@ -4938,24 +4936,17 @@ impl Editor {
|
|||
if selections[i - 1]
|
||||
.end
|
||||
.cmp(&selections[i].start, &*buffer)
|
||||
.unwrap()
|
||||
.is_ge()
|
||||
{
|
||||
let removed = selections.remove(i);
|
||||
if removed
|
||||
.start
|
||||
.cmp(&selections[i - 1].start, &*buffer)
|
||||
.unwrap()
|
||||
.is_lt()
|
||||
{
|
||||
selections[i - 1].start = removed.start;
|
||||
}
|
||||
if removed
|
||||
.end
|
||||
.cmp(&selections[i - 1].end, &*buffer)
|
||||
.unwrap()
|
||||
.is_gt()
|
||||
{
|
||||
if removed.end.cmp(&selections[i - 1].end, &*buffer).is_gt() {
|
||||
selections[i - 1].end = removed.end;
|
||||
}
|
||||
} else {
|
||||
|
@ -5429,7 +5420,7 @@ impl Editor {
|
|||
let buffer = &display_snapshot.buffer_snapshot;
|
||||
for (color, ranges) in self.background_highlights.values() {
|
||||
let start_ix = match ranges.binary_search_by(|probe| {
|
||||
let cmp = probe.end.cmp(&search_range.start, &buffer).unwrap();
|
||||
let cmp = probe.end.cmp(&search_range.start, &buffer);
|
||||
if cmp.is_gt() {
|
||||
Ordering::Greater
|
||||
} else {
|
||||
|
@ -5439,7 +5430,7 @@ impl Editor {
|
|||
Ok(i) | Err(i) => i,
|
||||
};
|
||||
for range in &ranges[start_ix..] {
|
||||
if range.start.cmp(&search_range.end, &buffer).unwrap().is_ge() {
|
||||
if range.start.cmp(&search_range.end, &buffer).is_ge() {
|
||||
break;
|
||||
}
|
||||
let start = range
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue