mirror of
https://github.com/zed-industries/zed.git
synced 2026-05-24 21:59:04 +00:00
text: Replace some more release panics with graceful fallbacks (#44542)
Fixes ZED-3P7 Release Notes: - N/A *or* Added/Fixed/Improved ...
This commit is contained in:
parent
0a816cbc87
commit
511e51c80e
1 changed files with 11 additions and 2 deletions
|
|
@ -39,6 +39,7 @@ pub use subscription::*;
|
|||
pub use sum_tree::Bias;
|
||||
use sum_tree::{Dimensions, FilterCursor, SumTree, TreeMap, TreeSet};
|
||||
use undo_map::UndoMap;
|
||||
use util::debug_panic;
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
use util::RandomCharIter;
|
||||
|
|
@ -2439,7 +2440,7 @@ impl BufferSnapshot {
|
|||
if bias == Bias::Left && offset == 0 {
|
||||
Anchor::min_for_buffer(self.remote_id)
|
||||
} else if bias == Bias::Right
|
||||
&& ((cfg!(debug_assertions) && offset >= self.len()) || offset == self.len())
|
||||
&& ((!cfg!(debug_assertions) && offset >= self.len()) || offset == self.len())
|
||||
{
|
||||
Anchor::max_for_buffer(self.remote_id)
|
||||
} else {
|
||||
|
|
@ -2453,7 +2454,15 @@ impl BufferSnapshot {
|
|||
};
|
||||
}
|
||||
let (start, _, item) = self.fragments.find::<usize, _>(&None, &offset, bias);
|
||||
let fragment = item.unwrap();
|
||||
let Some(fragment) = item else {
|
||||
// We got a bad offset, likely out of bounds
|
||||
debug_panic!(
|
||||
"Failed to find fragment at offset {} (len: {})",
|
||||
offset,
|
||||
self.len()
|
||||
);
|
||||
return Anchor::max_for_buffer(self.remote_id);
|
||||
};
|
||||
let overshoot = offset - start;
|
||||
Anchor {
|
||||
timestamp: fragment.timestamp,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue