Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Cursor positioned in wrong window when one or more windows were autoopen #6

Closed
lyokha opened this Issue · 2 comments

2 participants

@lyokha

I found that 'wincmd l' workaround must not be triggered when there are windows to autoopen (e.g. tagbar or NERDtree etc.). Simple fix is to additionally check if number of open windows is less than 3 (i.e. there are only 2 windows to diff). Here is a very simple patch against current repo version:

--- autoload/recover.vim    2012-04-20 04:42:54.000000000 +0400
+++ autoload/recover.vim.new    2012-06-17 17:41:51.320910297 +0400
@@ -76,9 +76,10 @@
        " Not sure, why this needs feedkeys
        " Sometimes cursor is wrong, I hate when this happens
        " Cursor is wrong only when there is a single buffer open, a simple
-       " workaround for that is to check if bufnr('') is 1: in this case
-       " ':wincmd l\n:0\n' must be fed
-       if bufnr('') == 1
+       " workaround for that is to check if bufnr('') is 1 and total number
+       " of windows in current tab is less than 3 (i.e. no windows were
+       " autoopen): in this case " ':wincmd l\n:0\n' must be fed
+       if bufnr('') == 1 && winnr('$') < 3
        call feedkeys(":wincmd l\n", 't')
        endif
        call feedkeys(":0\n", 't')

I tested this in different conditions (with and without autoopen windows, in current window / in new tagbar etc.): it seems to work fine.

Cheers, Alexey.

@lyokha

Sorry, a typo in comment, diff must be:

--- autoload/recover.vim    2012-04-20 04:42:54.000000000 +0400
+++ autoload/recover.vim.new    2012-06-17 18:03:56.577048852 +0400
@@ -76,9 +76,10 @@
        " Not sure, why this needs feedkeys
        " Sometimes cursor is wrong, I hate when this happens
        " Cursor is wrong only when there is a single buffer open, a simple
-       " workaround for that is to check if bufnr('') is 1: in this case
-       " ':wincmd l\n:0\n' must be fed
-       if bufnr('') == 1
+       " workaround for that is to check if bufnr('') is 1 and total number
+       " of windows in current tab is less than 3 (i.e. no windows were
+       " autoopen): in this case ':wincmd l\n:0\n' must be fed
+       if bufnr('') == 1 && winnr('$') < 3
        call feedkeys(":wincmd l\n", 't')
        endif
        call feedkeys(":0\n", 't')
@chrisbra
Owner
@chrisbra chrisbra closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.