Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reloading a file with expanded folds breaks them #37

Open
haasn opened this issue Jun 11, 2016 · 10 comments
Open

Reloading a file with expanded folds breaks them #37

haasn opened this issue Jun 11, 2016 · 10 comments

Comments

@haasn
Copy link

haasn commented Jun 11, 2016

If I make changes to a file outside of vim and reload that file, FastFold only correctly updates if all my folds are closed. If I have any expanded, something breaks and all of my folds start and stop at completely wrong positions.

This work-around seems to alleviate the problem:

au BufReadPre * setlocal foldmethod=syntax

That way vim will reload the folds correctly, before FastFold gets a chance to “cache” the wrong values.

@Konfekt
Copy link
Owner

Konfekt commented Jun 11, 2016

Do you have autoread set? Or do you manually reread the file in by :edit?

Ok, tentatively added your BufReadPre autocmd to handle this. Could you try?

Does BufRead work ? Why is it BufReadPre? Skimming through the autocmd triggers, there does not seem to be one expressly designed for reloading a buffer.

@haasn
Copy link
Author

haasn commented Jun 11, 2016

Do you have autoread set? Or do you manually reread the file in by :edit?

I have autoread set and update the files with :checktime. The way I am reproducing this is by running git commands from outside vim.

Does BufRead work ?

Yes. I only made it BufReadPre beacuse I didn't really look into it much, and just figured doing it this way would make sure it's set to ‘syntax’ during the moment vim actually loads the file (and then evaluates the folds), and before any of what fastfold was doing.

Skimming through the autocmd triggers, there does not seem to be one expressly designed for reloading a buffer.

I got the same impression from #vim.

@Konfekt
Copy link
Owner

Konfekt commented Jun 11, 2016

Thanks for clearinf that up. So is it fixed?

@haasn
Copy link
Author

haasn commented Jun 11, 2016

In master I get

E201: *ReadPre autocommands must not change current buffer                                                                           E321: Could not reload "video.c"
E201: *ReadPre autocommands must not change current buffer
E321: Could not reload "video.h"
E201: *ReadPre autocommands must not change current buffer
E321: Could not reload "user_shaders.c"
E201: *ReadPre autocommands must not change current buffer
E321: Could not reload "utils.c"
E201: *ReadPre autocommands must not change current buffer
E321: Could not reload "command.c"
E201: *ReadPre autocommands must not change current buffer
E321: Could not reload "input.rst"

@Konfekt
Copy link
Owner

Konfekt commented Jun 11, 2016

Hm. Please check again with BufRead. Cannot reproduce though when using :checktime after changinf outside of Vim. Also, FastFold does not change any buffer contents. If this doesn't fix it, please provide steps to reproduce with a minimal vimrc.

@haasn
Copy link
Author

haasn commented Jun 11, 2016

That seems to have fixed it.

Edit: Spoke too soon. Crash is gone but it still does not update folds properly. I'll try producing a minimal sample later, need sleep first.

@Konfekt
Copy link
Owner

Konfekt commented Jun 11, 2016

Strange. What FastFold now does is recomputing folds after the buffer was read in again by the BufRead trigger. So if you hit zuz say to update them manually, are folds fine ?

@Konfekt
Copy link
Owner

Konfekt commented Jun 11, 2016

But have some sleep first.

@Konfekt
Copy link
Owner

Konfekt commented Jun 13, 2016

Refined the autocmd and it works here. With the exception of pandoc markdown files whose fold method switches from expr to syntax. But Otherwise it is fine.

@Konfekt
Copy link
Owner

Konfekt commented Jun 13, 2016

Please make sure for FastFold tô function correctly, that the checktime autocmd is Nested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants