Skip to content

Commit 18657eb

Browse files
committed
Make fold levels be buffer local.
Without this I had behavior where doing `SignifyFold!` on a second buffer would change the fold regions of the first buffer. With the fix things were independent as they should be.
1 parent 8670143 commit 18657eb

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

autoload/sy/fold.vim

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
" SignifyFoldExpr {{{1
44
function! SignifyFoldExpr(lnum)
5-
return s:levels[a:lnum]
5+
return b:levels[a:lnum]
66
endfunction
77

88
" SignifyFoldText {{{1
@@ -48,8 +48,8 @@ function! sy#fold#enable(do_tab) abort
4848
tabedit %
4949
endif
5050

51-
let [s:context0, s:context1] = get(g:, 'signify_fold_context', [3, 8])
52-
let s:levels = s:get_levels(s:get_lines())
51+
let [context0, context1] = get(g:, 'signify_fold_context', [3, 8])
52+
let b:levels = s:get_levels(s:get_lines(), context0, context1)
5353

5454
setlocal foldexpr=SignifyFoldExpr(v:lnum)
5555
setlocal foldtext=SignifyFoldText()
@@ -92,22 +92,22 @@ function! s:get_lines() abort
9292
endfunction
9393

9494
" s:get_levels {{{1
95-
function! s:get_levels(lines) abort
95+
function! s:get_levels(lines, context0, context1) abort
9696
let levels = {}
9797

9898
for line in range(1, line('$'))
9999
let levels[line] = 2
100100
endfor
101101

102102
for line in a:lines
103-
for l in range(line - s:context1, line + s:context1)
103+
for l in range(line - context1, line + context1)
104104
if (l < 1) || (l > line('$'))
105105
continue
106106
endif
107107
if levels[l] == 2
108108
let levels[l] = 1
109109
endif
110-
for ll in range(line - s:context0, line + s:context0)
110+
for ll in range(line - context0, line + context0)
111111
let levels[ll] = 0
112112
endfor
113113
endfor

0 commit comments

Comments
 (0)