Skip to content

Commit

Permalink
Fix panic on paste from blackhole register (helix-editor#4497)
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
the-mikedavis authored and Shekhinah Memmel committed Dec 11, 2022
1 parent 0b509ae commit 0a399f6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3487,7 +3487,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)))
Expand Down

0 comments on commit 0a399f6

Please sign in to comment.