Skip to content

Commit

Permalink
fix stuck while refresh fix #170 #36
Browse files Browse the repository at this point in the history
On first refresh, vimagit can be stuck during several seconds.
foldmethod=syntax seems to be the culprit.

Longer explanation:

Remove folding while we are updating the buffer. writing to the buffer
while the folding is enabled can be veryyyyy slow.
One last strange thing is that, the first time the buffer is written, it
is not slow at all. It is slow the second time, at first refresh (can be
order of seconds). Then at third time (2nd refresh), it is fast again.
  • Loading branch information
jreybert committed Oct 12, 2018
1 parent 3340dfd commit 39b9aa6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion plugin/magit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,16 @@ function! magit#update_buffer(...)

" remove all signs (needed as long as we wipe buffer)
call magit#sign#remove_all()


" remove folding while we are updating the buffer. writing to the buffer
" while the folding is enabled can be veryyyyy slow.
" One last strange thing is that, the first time the buffer is written, it
" is not slow at all. It is slow the second time, at first refresh (can be
" order of seconds). Then at third time (2nd refresh), it is fast again.
" refs:
" https://github.com/jreybert/vimagit/issues/170
" https://github.com/jreybert/vimagit/issues/36 (maybe)
setlocal foldmethod=manual
" delete buffer
silent! execute "silent :%delete _"

Expand Down Expand Up @@ -631,6 +640,7 @@ function! magit#update_buffer(...)
call magit#utils#clear_undo()

setlocal filetype=magit
setlocal foldmethod=syntax

if ( b:magit_current_commit_mode != '' && b:magit_commit_newly_open == 1 )
let commit_section_pat_start='^'.g:magit_sections.commit.'$'
Expand Down

0 comments on commit 39b9aa6

Please sign in to comment.