Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork772
Make folding much faster in some cases#743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Cache the results of Is_opening_folding once per change so it doesn'tloop over the same lines multiple times unnecessarily.
fmv1992 commentedMar 9, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I have updated the folding code again:https://github.com/fmv1992/python-mode/tree/improve_folding As the code is here: it does not cover all cases for docstrings and there is also a bug (see below). Right now I have a solution working but the folding is very slow and it creates more auxiliary functions (that do not have your cacheing solution). Would you take a look and help me port your solution to this scenario? Bug sample:
|
I took a look and you can make it a little faster by doing similar caching on the IsDefinitionStatement function, but the bottleneck is the searchpairpos function and I don't see a way around that. If the results were perfect, I'd say that's probably acceptable in terms of speed. However I noticed a bug soon after testing it out, e.g.
That example starts a fold at the line with the import statement. |
That was fortunate/unfortunate. With the old definition regex I investigated the nature of folding and they get updated during insert mode. From here on I see two alternatives:
Any thoughts? |
Personally I use the FastFold plugin to prevent folds updating during insert mode. I suspect a lot of people do the same because updating folds in insert mode is already pretty slow with the current folding function. I don't see any need to update the folds in insert mode so I value correctness over speed to some extent. |
Thanks. Finding out about this improved my vim experience. Should this be incorporated in pymode? Specially if we invest in the full folding case. |
Sorry, I'm not sure what you're asking. Are you asking if I think your |
No. This branch needs some work anyways. But I think it should be a good idea to let folding be updated only upon saving or other 'rarer' event other than each key you type in insert mode. |
I agree that updating less frequently is better but making that a feature of pymode might interfere with autocommands or plugins users have for that purpose. I don't think it's necessary. |
Cache the results of Is_opening_folding once per change so it doesn't loop over the same lines multiple times unnecessarily. For autopep8.py for example, this reduced folding time from >10 seconds to near instantaneous.