aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorMichael Davis2022-11-04 16:04:16 +0000
committerGitHub2022-11-04 16:04:16 +0000
commit38149872989477f62222ce68dc32d2d6018ae165 (patch)
tree5b7f2130ccb01d4afa5b6e3e4ef31ef3120f17fc /helix-term/src
parentd6323b7cbc21a9d3ba29738c76581dad93f9f415 (diff)
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`.
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index a6ee6263..ef963477 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -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)))