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

Bad fold interaction with sessions #31

Open
ches opened this issue Jul 15, 2016 · 1 comment
Open

Bad fold interaction with sessions #31

ches opened this issue Jul 15, 2016 · 1 comment
Assignees

Comments

@ches
Copy link

ches commented Jul 15, 2016

Hi, thanks for the plugin!

I use vim-session, and unfortunately Braceless's folding seems to result in some undesirable interaction with it. vim-session persists manual folds in its session files, so I'm guessing that's the crux of the problem. Actually, standard :mksession does too, so similar problems might crop up with usage of the native session support.

Basically, the annoying behavior is this:

  1. Open a session for the first time with BracelessEnable +fold in effect.
  2. Invoke closing a fold (I think this is necessary once, to trigger computation of the manual folds).
  3. Save and close the session, with no folds closed in the file.
  4. Open it again. All the folds are closed. Or at least most of them, maybe the scope of the one block that had been folded, I can't quite tell exactly.

So now I have to manually zR everything every time I re-open a session. I have set foldlevelstart=99 as a default in my config, but I'm assuming that Braceless's fold approach doesn't or can't support that. Or maybe the manual folds saved in the session subvert it upon restore.

If I disable Braceless, re-open the session, zE on the buffers, save session and re-open it, all is well again. Until Braceless is enabled again… I could try to bufdo zE when closing sessions with an autocommand or something, but Braceless won't allow that.

Any ideas about how this situation could be improved?

@tweekmonster tweekmonster self-assigned this Jul 16, 2016
@tweekmonster
Copy link
Owner

I think the issue I'm seeing is how the session is generating the fold commands, which seems to be caused by overlapping folds created by this plugin. The best way to deal with this is probably to only create shallow folds for the current cursor instead of trying to preemptively create all the folds for a block. In addition, destroy the fold if it's opened. That way the generated session script could only mess with the folds it sees.

I'm not a big fan of how folding is handled by Vim in general. In particular, the fact that there isn't a "ignore foldlevel and foldstartlevel entirely" option.

The way I'm dealing with it is forcing all buffers to start with all folds open:

autocmd BufWinEnter,SessionLoadPost * silent! %foldopen!

This way, you won't need the goofy foldstartlevel=99. You could change it to just *.py if you want to keep how folds work in other filetypes.

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