Fix panic when doing various cursor movements with a pending mouse selection (#13016)
This fixes a panic in the `SelectionsCollection::first_anchor` when
there was a pending mouse selection and no other selections. Until
recently, this method was only used in vim mode, but as of
53b0720d54
,
it's also used in the normal `move_up` and `move_down` actions.
So until recently, the panic that this fixes could only happen in vim
mode.
Release Notes:
- Fixed a crash that could happen when using certain cursor-motion
bindings with a pending mouse selection.
This commit is contained in:
parent
01ba1ddef7
commit
066cdc2297
2 changed files with 40 additions and 1 deletions
|
@ -256,7 +256,10 @@ impl SelectionsCollection {
|
|||
}
|
||||
|
||||
pub fn first_anchor(&self) -> Selection<Anchor> {
|
||||
self.disjoint[0].clone()
|
||||
self.pending
|
||||
.as_ref()
|
||||
.map(|pending| pending.selection.clone())
|
||||
.unwrap_or_else(|| self.disjoint.first().cloned().unwrap())
|
||||
}
|
||||
|
||||
pub fn first<D: TextDimension + Ord + Sub<D, Output = D>>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue