FastFold might slow down Vim a lot (vimrc, fdm=marker)
blueyed opened this issue · 8 comments
I've seen it a few times already, that Vim got very slow when editing my (huge) vimrc file, after I've installed FastFold recently.
This is not reproducible and using :FastFoldUpdate
/ zuz
or :e
eventually fixes it.
I could not find anything using :debug norm j
(nothing was executed), nor by profiling Vim (using :profile
).
Is there a way to debug this?
Is it possible to list all manual folds?
I am using the following modeline:
" vim: fdm=marker
You can see my vimrc at: https://github.com/blueyed/dotfiles/blob/master/vimrc - although there are a lot of local changes.
That's not reproducible over here. Vim rests snappy even editing blueyedvimrc.vim
.
Hmm.. what do you mean by listing all manual folds? FastFold usually overwrites manual folds.
That said, it makes sense to add an option, maybe even set default, that FastFold only hooks in when foldmethod = expr
or foldmethod=syntax
as all other methods require little computation.
That's not reproducible over here
I cannot reproduce it either, but seen it happen a few times.
what do you mean by listing all manual folds? FastFold usually overwrites manual folds.
FastFold might get something wrong there, similar to Vim's syntax handling where you might need :syn sync fromstart
to fix it.
Having a way to list the manual folds might help then.
I agree that an option to only handle expr
and syntax
would make sense.
Ok. I implemented it. Give it a try, and perhaps check the diff if it seems reasonable.
Offtopic: The name wildfire
of a plugin of yours got me curious. Very handy. You should also check the anyblock
text object plugin.
Thanks! (for reference: the commit).
It seems like the plugin does nothing (too) special, but "only" sets fdm=manual
?!
I've noticed that the EnterAll
and LeaveAll
methods should probably
a) get wrapped by tabdo
also
b) restore the previous window/tab
See http://vim.wikia.com/wiki/Run_a_command_in_multiple_buffers#Restoring_position.
Also, the name of these functions is a bit misleading, as their purpose appears to be finding / handling all windows with the current buffer.
Instead of tabdo
/ windo
you could loop through them with more control.
For looping over the tabs, with the current one being the first see: https://github.com/blueyed/vim-diminactive/blob/master/plugin/diminactive.vim#L302-L315, and then for looping the windows on a specific tab: https://github.com/blueyed/vim-diminactive/blob/master/plugin/diminactive.vim#L84-L90.
Offtopic: thanks for the anyblock
suggestion, I'll check it out.
Yes, it sets fdm=manual
by default but briefly switches to the fold method set by the user (syntax
or expr
) when saving, opening/closing folds or manually forcing an update via zuz
or FastFoldUpate!
.
Ok, if the window list is tabwise, FastFold also has to loop through the tabs. I'll implement your proposed solutions later on.
The other issues, including, the indenting, should be fixed by the latest commit.
Ok, I took the pedestrian's solution from vim wikia to account for windows on different tab pages.
Give it a try and let me know of any possible quirks since I rarely encounter the situation of a buffer being displayed in windows on different tabs.
If you think your solution helps avoiding overhead, I am happy to discuss but for now the naive solution seems as simple as effective.
Lots of commits to clean up quirks..