From 96a90035ca507ec3da116e8f887ff4967b6cd9ec Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 26 Sep 2010 17:56:37 +0200 Subject: vim_mode: Fix p at the end of the line. --- vim-mode/vim_mode.pl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index e372050..39752fc 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -430,7 +430,13 @@ sub _paste_at_position { my $string = $registers->{'"'} x $count; my $input = _input(); - substr($input, $pos, 0) = $string; + # Check if we are not at the end of the line to prevent substr outside of + # string error. + if (length $input > $pos) { + substr($input, $pos, 0) = $string; + } else { + $input .= $string; + } _input($input); _input_pos($pos - 1 + length $string); -- cgit v1.2.3