mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-25 01:34:02 +00:00
Fix out-of-range panic when requesting outline items at EOF
This commit is contained in:
parent
587175d0ea
commit
3245e4f8d7
1 changed files with 4 additions and 2 deletions
|
@ -1953,8 +1953,10 @@ impl BufferSnapshot {
|
|||
theme: Option<&SyntaxTheme>,
|
||||
) -> Option<Vec<OutlineItem<Anchor>>> {
|
||||
let position = position.to_offset(self);
|
||||
let mut items =
|
||||
self.outline_items_containing(position.saturating_sub(1)..position + 1, theme)?;
|
||||
let mut items = self.outline_items_containing(
|
||||
position.saturating_sub(1)..self.len().min(position + 1),
|
||||
theme,
|
||||
)?;
|
||||
let mut prev_depth = None;
|
||||
items.retain(|item| {
|
||||
let result = prev_depth.map_or(true, |prev_depth| item.depth > prev_depth);
|
||||
|
|
Loading…
Reference in a new issue