aboutsummaryrefslogtreecommitdiffstats
path: root/vim-mode/vim_mode.pl
diff options
context:
space:
mode:
authorSimon Ruderich <simon@ruderich.org>2010-09-27 00:50:23 +0000
committerSimon Ruderich <simon@ruderich.org>2010-09-27 00:50:23 +0000
commitd3a86527ee56cf5654acff9dd25edaa87dd2b828 (patch)
tree92f6004e7042b18fe1782773292f357038c3e3da /vim-mode/vim_mode.pl
parentvim_mode: Add G to switch to count-th window. (diff)
downloadirssi-scripts-d3a86527ee56cf5654acff9dd25edaa87dd2b828.tar.gz
irssi-scripts-d3a86527ee56cf5654acff9dd25edaa87dd2b828.zip
vim_mode: G with no count goes to the last window.
Diffstat (limited to 'vim-mode/vim_mode.pl')
-rw-r--r--vim-mode/vim_mode.pl13
1 files changed, 12 insertions, 1 deletions
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();