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

Consider replacing current window stabilizer with this one: #67

Open
jordwalke opened this issue Dec 3, 2019 · 2 comments
Open

Consider replacing current window stabilizer with this one: #67

jordwalke opened this issue Dec 3, 2019 · 2 comments

Comments

@jordwalke
Copy link
Owner

https://github.com/gillyb/stable-windows

@gillyb - looks like we have some overlapping code/purposes.

@jordwalke
Copy link
Owner Author

I am curious how you figured out how to do this. It turns out it's incredibly hard, and not 100% possible when considering windows that have splits. Have you found the same?

@gillyb
Copy link

gillyb commented Dec 3, 2019

Took me a while to think of a good solution for this problem, because there's no auto command available that covers all the cases of leaving a buffer/window/split.

What I ended up doing is keeping an object that stores the cursor line for each window/split/buffer you're in. I update this object on every cursor movement. (This sounds like it can slow vim down, but it's only updating a single variable. From my experience it didn't slow anything down).
Then on the autocommand "WinEnter" I loop through all the buffers and align their cursors and the top line to what they were just before the WinEnter command (which is just before the windows alignment moved).

I think the code is pretty readable, I tried to add comments so I'll remember what I did myself :)
But if you have any questions i'll be happy to help.

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