Fix panic on paste from blackhole register (#4497)

The sequence "_y"_p panics because the blackhole register contains an
empty values vec. This causes a panic when pasting since it unwraps
a `slice::last`.
This commit is contained in:
Michael Davis 2022-11-04 11:04:16 -05:00 committed by GitHub
parent d6323b7cbc
commit 3814987298
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3447,7 +3447,12 @@ enum Paste {
}
fn paste_impl(values: &[String], doc: &mut Document, view: &mut View, action: Paste, count: usize) {
if values.is_empty() {
return;
}
let repeat = std::iter::repeat(
// `values` is asserted to have at least one entry above.
values
.last()
.map(|value| Tendril::from(value.repeat(count)))