Monday, October 24, 2011

Views causing changes to text on buffer change

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOpXQvAAoJEGtKWn4hIN6V9b0P/0MlRnwZCy4C9nv8irRjWRe3
RKfmPJ/aUtSu+XKd7m7ba+ptqDbct8lzeQ2IAJG9hzvgaFoH9kw4zdXlLmUFssBs
DeqMdWqr2uD8nj3WncZTxZ9OQt/JoXncwOS56q925Lq1xwIUj2Iy9TP8Yt4eOpSR
slZqmAsZNLhUSQVFKtGJquPeTCU6Y4j97Y7o/t9TXGG2YlkAqaxfgY9I8QM963Zd
h01vd/ptBB7WHMfwtTxYYTEzQKGRmoCs4WMBFOY3jRhk3Iz6WECM0rc1wzi039CJ
U12BUusCjxxgSxL+LNDWxrka+mNR13eHM+dqx89zQK6hdLM97Uegrb7/3uIXUbL2
MFPld807iLhW6r9yu7Bbwt1191r/tCi49PhOLPTn0x3oWnc5voinvtEVxP9OBsRx
0aQu5XDhJEqGIYr1QVk9cs/3haWYgNnuK3TANwV2Laf4b9HJs/nE1fvHrOaf3D6w
+iUG2ygPKNF3hnAcmHUgkYHNQO4nXZiPe+6GBhDH8okxZfYmVYShQauzH2OubTHB
7XQ7zTXq2rW4vPF/+4QBtDK5XVREYWENMg29XufBXq3YtK3nI/T8KqJcRuRymPiX
ja0lpoYsZz6SR95QhXSDMHwZ4VbATohbV4MiiSvHtaX8Dlv7314/2kO/Sgpxz0oA
ByYa0Ld2rMIKRJ8E2WeM
=5RZ/
-----END PGP SIGNATURE-----
I've been having an issue with buffers changing their content when I
switch between them with :bNext and :bPrevious, assuming that :set
hidden is on. This scenario is perfectly reproducible:

Load two or more files, make a change in file A, :bNext to a different
file, then back to file A. The file will have gotten an empty line added
after the last place of editing (regardless of whether I saved before or
not). If I then switch back and forth, there's no change, but the empty
line is there.

Another symptom, that I don't know exactly when it happens but I know
happens regularly, would be the exact same situation as before, but
instead of a new empty line, the latest edited state is undo'd a step or
two backwards (this also regardless of whether I saved or not).

After disabling things one by one in my .vimrc and disabling all of my
plugins, I narrowed it down to the point that I found out that these two
lines were what caused the issue:

au BufWinLeave ?* mkview
au BufWinEnter ?* silent loadview

These lines were taken from this page:
http://vim.wikia.com/wiki/Make_views_automatic
The purpose was to make folds get saved. Obviously this side effect of
buffers behaving strangely is something that gets in my way though, and
I think I prefer having a working buffer switching instead of saved
folds, but optimally I'd like to have both.

Does anyone know if there's a way around this issue?

No comments: