kalekundert/vim-coiled-snake

Plugin changes the global options foldmethod and foldtext

Closed this issue · 2 comments

I assume the changes from 17 days ago where the cause of this bug.
The consequence of this bug is that for buffers in which the options foldmethod and foldtext are not set explicitly they get their values from the previously active one.
The cause is that statements like "let &foldmethod = ..." change the global options.
I succeded in changing such a statement to "let &l:foldmethod = ...".
At least the "bleeding" of the options does not occur any more.
The following are the changed lines in the autoload file:
174: let &l:foldtext = 'coiledsnake#FoldText()'
180: let &l:foldexpr = 'coiledsnake#FoldExpr(v:lnum)'
181: let &l:foldmethod = 'expr'
188: let &l:foldtext = get(w:, 'coiled_snake_saved_foldtext', &foldtext)
192: let &l:foldexpr = get(w:, 'coiled_snake_saved_foldexpr', &foldexpr)
193: let &l:foldmethod = get(w:, 'coiled_snake_saved_foldmethod', &foldmethod)

EDIT: I just saw the documentation about :h :let-& and am genuinely astonished to see the truth. I really wasn't aware of this detail. Thank you very much for the insight 👍

The issue shall be fixed soon. (In fact, you have already fixed it for us 😄)


The cause is that statements like "let &foldmethod = ..." change the global options.

But isn't that option local-to-window? 😲

I really appreciate your effort to find out the bug yourself and try to fix it, and also inform us about what caused this bug and why. This is really high-quality!