Fix panic in enclosing bracket ranges (#8870)
This function was operating in the wrong co-ordinate space (c.f. #8081) Release Notes: - Fixed a panic on `ctrl-m` in a multibuffer
This commit is contained in:
parent
27c5343707
commit
e0c66b30c8
1 changed files with 11 additions and 2 deletions
|
@ -195,7 +195,7 @@ struct Excerpt {
|
||||||
///
|
///
|
||||||
/// Contains methods for getting the [`Buffer`] of the excerpt,
|
/// Contains methods for getting the [`Buffer`] of the excerpt,
|
||||||
/// as well as mapping offsets to/from buffer and multibuffer coordinates.
|
/// as well as mapping offsets to/from buffer and multibuffer coordinates.
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Clone)]
|
||||||
pub struct MultiBufferExcerpt<'a> {
|
pub struct MultiBufferExcerpt<'a> {
|
||||||
excerpt: &'a Excerpt,
|
excerpt: &'a Excerpt,
|
||||||
excerpt_offset: usize,
|
excerpt_offset: usize,
|
||||||
|
@ -2963,7 +2963,16 @@ impl MultiBufferSnapshot {
|
||||||
excerpt
|
excerpt
|
||||||
.buffer()
|
.buffer()
|
||||||
.enclosing_bracket_ranges(excerpt.map_range_to_buffer(range))
|
.enclosing_bracket_ranges(excerpt.map_range_to_buffer(range))
|
||||||
.filter(move |(open, close)| excerpt.contains_buffer_range(open.start..close.end)),
|
.filter_map(move |(open, close)| {
|
||||||
|
if excerpt.contains_buffer_range(open.start..close.end) {
|
||||||
|
Some((
|
||||||
|
excerpt.map_range_from_buffer(open),
|
||||||
|
excerpt.map_range_from_buffer(close),
|
||||||
|
))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue