Return last excerpt in MultiBuffer::excerpt_containing if overshooting
This commit is contained in:
parent
6e37ff880f
commit
b3c7526fb5
1 changed files with 15 additions and 12 deletions
|
@ -1082,18 +1082,21 @@ impl MultiBuffer {
|
||||||
|
|
||||||
let mut cursor = snapshot.excerpts.cursor::<usize>();
|
let mut cursor = snapshot.excerpts.cursor::<usize>();
|
||||||
cursor.seek(&position, Bias::Right, &());
|
cursor.seek(&position, Bias::Right, &());
|
||||||
cursor.item().map(|excerpt| {
|
cursor
|
||||||
(
|
.item()
|
||||||
excerpt.id.clone(),
|
.or_else(|| snapshot.excerpts.last())
|
||||||
self.buffers
|
.map(|excerpt| {
|
||||||
.borrow()
|
(
|
||||||
.get(&excerpt.buffer_id)
|
excerpt.id.clone(),
|
||||||
.unwrap()
|
self.buffers
|
||||||
.buffer
|
.borrow()
|
||||||
.clone(),
|
.get(&excerpt.buffer_id)
|
||||||
excerpt.range.context.clone(),
|
.unwrap()
|
||||||
)
|
.buffer
|
||||||
})
|
.clone(),
|
||||||
|
excerpt.range.context.clone(),
|
||||||
|
)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// If point is at the end of the buffer, the last excerpt is returned
|
// If point is at the end of the buffer, the last excerpt is returned
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue