Speed improvement with folding enabled
The 'foldmethod' was being reset every time the cursor entered a vimwiki, causing an unnecessary large delay. So it was changed to set it only the first time the buffer is loaded into a window. This greatly improves performance when switching between vim tabs. Fold settings are also reapplied after using 'diffoff'. Added test/ directory with sample file and instructions for testing this change. Fixes #580
This commit is contained in:
parent
510c149512
commit
2b6fa274a8
@ -102,12 +102,22 @@ function! s:setup_buffer_enter()
|
||||
return
|
||||
endif
|
||||
|
||||
call s:set_global_options()
|
||||
endfunction
|
||||
|
||||
|
||||
" this is called when the buffer enters a window or when running a diff
|
||||
function! s:setup_buffer_win_enter()
|
||||
" don't do anything if it's not managed by Vimwiki (that is, when it's not in
|
||||
" a registered wiki and not a temporary wiki)
|
||||
if vimwiki#vars#get_bufferlocal('wiki_nr') == -1
|
||||
return
|
||||
endif
|
||||
|
||||
if &filetype != 'vimwiki'
|
||||
setfiletype vimwiki
|
||||
endif
|
||||
|
||||
call s:set_global_options()
|
||||
|
||||
call s:set_windowlocal_options()
|
||||
endfunction
|
||||
|
||||
@ -302,6 +312,10 @@ augroup vimwiki
|
||||
exe 'autocmd BufNewFile,BufRead *'.s:ext.' call s:setup_new_wiki_buffer()'
|
||||
exe 'autocmd BufEnter *'.s:ext.' call s:setup_buffer_enter()'
|
||||
exe 'autocmd BufLeave *'.s:ext.' call s:setup_buffer_leave()'
|
||||
exe 'autocmd BufWinEnter *'.s:ext.' call s:setup_buffer_win_enter()'
|
||||
if exists('##DiffUpdated')
|
||||
exe 'autocmd DiffUpdated *'.s:ext.' call s:setup_buffer_win_enter()'
|
||||
endif
|
||||
" automatically generate a level 1 header for new files
|
||||
exe 'autocmd BufNewFile *'.s:ext.' call s:create_h1(expand("%:p"))'
|
||||
" Format tables when exit from insert mode. Do not use textwidth to
|
||||
|
10923
tests/resources/delay.wiki
Executable file
10923
tests/resources/delay.wiki
Executable file
File diff suppressed because it is too large
Load Diff
18
tests/tabnext_delay.txt
Normal file
18
tests/tabnext_delay.txt
Normal file
@ -0,0 +1,18 @@
|
||||
" From https://github.com/vimwiki/vimwiki/pull/601
|
||||
$ gvim -u NONE -U NONE -N -i NONE
|
||||
<commands below can be copied to clipboard and run with `:@+`>
|
||||
set nocompatible
|
||||
filetype plugin on
|
||||
syntax on
|
||||
let g:vimwiki_camel_case = 0 " Don't make links from CamelCased words
|
||||
let g:vimwiki_table_auto_fmt = 0 " Turn off table auto-formatting
|
||||
let g:vimwiki_autowriteall = 0
|
||||
let g:vimwiki_folding = 'expr:quick' " Enable folding.
|
||||
let &rtp.=',~/.vim/bundle/vimwiki'
|
||||
source ~/.vim/bundle/vimwiki/plugin/vimwiki.vim
|
||||
e ~/tmp/delay.wiki
|
||||
normal! 50%
|
||||
normal! zozo
|
||||
tabe
|
||||
let start = reltime() | tabprev | redraw | echom reltimestr(reltime(start))
|
||||
" >>> expected: less than 0.5 seconds
|
Loading…
Reference in New Issue
Block a user