on master help sign in
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`.

commit38149872989477f62222ce68dc32d2d6018ae165 authorMichael Davis <mcarsondavis@gmail.com> dateFri 4 Nov 2022, 11:04 (4 years ago) parentd6323b7
1 file changed+5
helix-term/src/commands.rs+5
helix-term/src/commands.rs+5
@@ -3447,7 +3447,12 @@ enum Paste {
34473447}
34483448
34493449fn paste_impl(values: &[String], doc: &mut Document, view: &mut View, action: Paste, count: usize) {
3450+ if values.is_empty() {
3451+ return;
3452+ }
3453+
34503454 let repeat = std::iter::repeat(
3455+ // `values` is asserted to have at least one entry above.
34513456 values
34523457 .last()
34533458 .map(|value| Tendril::from(value.repeat(count)))