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

:ClangFormat always folds code when run #66

Open
cglosser opened this issue Jun 29, 2017 · 3 comments
Open

:ClangFormat always folds code when run #66

cglosser opened this issue Jun 29, 2017 · 3 comments
Labels

Comments

@cglosser
Copy link

Is there a way to run the formatter without triggering automatic code folding? Presumably this happens because I have vim setup to fold code when opening a C++ file and :ClangFormat reopens the file after it has done its thing. It would be great if vim-clang-format had some way to disable this so as to avoid having to drill down through a bunch of folds.

@rhysd rhysd added the bug label Jun 29, 2017
@rhysd
Copy link
Owner

rhysd commented Jun 30, 2017

I noticed that it's hard to maintain folding between the before and the after of formatting. For example, when a formatter found unnecessary { ... } block (e.g. body of if statement), it would remove the block. Removing block means the change of folding level. We can't detect it from Vim and vim-clang-format can't know which fold level it should open.

However, closing all folds after formatting is annoying as you pointed. I think I can try to implement some heuristics to reduce the problem, although it's not perfect.

@rhysd
Copy link
Owner

rhysd commented Jun 30, 2017

I added code to maintain fold level at cursor line as much as possible in 1cf402c. Please try the latest and check the behavior is what you want.

@cglosser
Copy link
Author

cglosser commented Jul 5, 2017

I haven't noticed any difference in behavior, but that could easily be due to other settings I have. Do you have an example I can check?

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

No branches or pull requests

2 participants