From 0a399f648d52149f7776db38fbc51bd2fd3552d5 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Fri, 4 Nov 2022 11:04:16 -0500 Subject: [PATCH] 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`. --- helix-term/src/commands.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 98c68b8783f6..305cc31e719d 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -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)))