Error when using trick to avoid scrolling when switch buffers #161

Closed
onilton opened this Issue May 29, 2014 · 3 comments

2 participants

@onilton

I use this trick in my .vimrc

http://vim.wikia.com/wiki/Avoid_scrolling_when_switch_buffers

" When switching buffers, preserve window view.
if v:version >= 700
  au BufLeave * if !&diff | let b:winview = winsaveview() | endif
  au BufEnter * if exists('b:winview') && !&diff | call winrestview(b:winview) | endif
endif

But when using this trick, when I switch buffers, snipmate get's weird behavior:
I am at buffer 1, scroll the screen a little bit, snipmate works ok, (for example, for if snippet in php).
then I switch to buffer 2 and then scroll the screen a little bit.
Now I go back to buffer 1, when I use the if snippet again I get a error message telling snipmate couldn't find if.

But after skipping the message I get the complete if snippet in another line (a few lines above or below), not the current line.

When I comment those trick to preserve window view in my .vimrc, snipmate doesn't present this behaviour.

@ajzafar
Collaborator

As far as I can tell, this only happens with multisnip and is caused by a stale b:winview hanging around. Removing it seems to fix it for me:

" When switching buffers, preserve window view.
if v:version >= 700
  au BufLeave * if !&diff | let b:winview = winsaveview() | endif
  au BufEnter * if exists('b:winview') && !&diff | call winrestview(b:winview) | unlet! b:winview | endif
endif
@onilton

Yes, this seems to solve the issue for me. Thanks a lot.
About what to do now, should I change vim's wiki page?

And about this issue, should I close it?

@ajzafar
Collaborator

About what to do now, should I change vim's wiki page?

Probably. And the issue is closed. :)

@ajzafar ajzafar closed this May 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment