Skip to content

Commit 46af4cd

Browse files
Fix cancelling insert mode (#546)
* Fix cancelling insert mode * Revert "get proper window number (#541)" This reverts commit 59daf85.
1 parent 89fd281 commit 46af4cd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

autoload/lsp/ui/vim/folding.vim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,15 @@ 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+
181186
" Set 'foldmethod' back to 'expr', which forces a re-evaluation of
182187
" 'foldexpr'. Only do this if the user hasn't changed 'foldmethod',
183188
" and this is the correct buffer.
184-
let l:current_window = bufwinnr()
189+
let l:current_window = winnr()
185190
windo if &l:foldmethod ==# 'expr' && bufnr('%') == l:bufnr | let &l:foldmethod = 'expr' | endif
186191
execute l:current_window . 'wincmd w'
187192
endfunction

0 commit comments

Comments
 (0)