From d3a86527ee56cf5654acff9dd25edaa87dd2b828 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 27 Sep 2010 02:50:23 +0200 Subject: vim_mode: G with no count goes to the last window. --- vim-mode/vim_mode.pl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 63ef6c1..925c4a6 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -46,6 +46,8 @@ use strict; use warnings; +use List::Util; + use Irssi; use Irssi::TextUI; # for sbar_items_redraw @@ -601,6 +603,11 @@ sub _paste_at_position { sub cmd_movement_G { my ($count, $pos) = @_; + # If no count is given go to the last window (= highest refnum). + if (not $count) { + $count = List::Util::max(map { $_->{refnum} } Irssi::windows()); + } + my $window = Irssi::window_find_refnum($count); if ($window) { $window->set_active(); @@ -852,7 +859,11 @@ sub handle_command { if ($skip) { print "Skipping movement and operator." if DEBUG; } else { - $numeric_prefix = 1 if not $numeric_prefix; + # Make sure count is at least 1, except for G which needs to + # handle undef specially. + if (not $numeric_prefix and $char ne 'G') { + $numeric_prefix = 1; + } # Execute the movement (multiple times). my $cur_pos = _input_pos(); -- cgit v1.2.3