Skip to content

Commit a1860ae

Browse files
authored
Merge pull request #557 from hrsh7th/fix-folding-visual
Fix canceling visual-mode when folding enabled.
2 parents efff126 + 28efdd0 commit a1860ae

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

autoload/lsp/ui/vim/folding.vim

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,13 @@ function! s:handle_fold_request(server, data) abort
178178
endif
179179
let s:folding_ranges[a:server][l:bufnr] = l:result
180180

181-
" Don't do the 'windo' in Insert mode, it puts Vim back in Normal mode.
182-
if mode()[0] ==# 'i'
183-
return
184-
endif
185-
186181
" Set 'foldmethod' back to 'expr', which forces a re-evaluation of
187182
" 'foldexpr'. Only do this if the user hasn't changed 'foldmethod',
188183
" and this is the correct buffer.
189-
let l:current_window = winnr()
190-
windo if &l:foldmethod ==# 'expr' && bufnr('%') == l:bufnr | let &l:foldmethod = 'expr' | endif
191-
execute l:current_window . 'wincmd w'
184+
for l:winid in win_findbuf(l:bufnr)
185+
if getwinvar(l:winid, '&foldmethod') ==# 'expr'
186+
call setwinvar(l:winid, '&foldmethod', 'expr')
187+
endif
188+
endfor
192189
endfunction
190+

0 commit comments

Comments
 (0)