Open durka opened 11 months ago
Wow, I think I'd actually swapped around the vertical split positioning by accident 😅. I swapped them around and vertical splits should now be restored in their correct position. I don't use vertical splits often myself, but I really should have tested this out properly.
I'm also seeing issues such as: :vsp, then :sp, if I close the original window (the one that wasn't split by :sp) and then restore, it re-splits horizontally instead of vertically.
Hm, I think the reason is the plugin looks for a neighboring buffer to reopen a window from, and it should be looking for a window instead, so it can handle duplicates. Since a :split
without an argument will open a new window backed with the same buffer. I'll see about getting that to work.
I think I managed to push a fix for this particular scenario as well. Could you try it out and let me know? I did find some other cases that might be problematic, I'll explore them separately.
I'm still seeing issues when mixing vertical and horizontal splits, I realize this may be hard to fix.
| a |
| a | b |
| | b |
| a | - |
| | c |
Now if I close a and try to restore it, it splits c instead of bringing back the left window.
Yeah, there's a few tricky scenarios. I think the best approach is to try to find the "best" neighbour to restore from, which would be a horizontal with the same height or a vertical with the same width. I'll see what I can do, though it might take a bit of time to get around to it.
@durka Sorry it took a while, I believe I've fixed this case as well:
Now if I close a and try to restore it, it splits c instead of bringing back the left window.
As I explained above, I tried to find the "best" window to restore from to maintain the layout. There is still one case that won't work right, but I can't think of a way to implement it, and I think it ought to be rare enough to not be that big of a problem.
If you have the time, I'd appreciate if you updated and tried out your cases to confirm if I've gotten it working or if there's another issue.
The plugin partially works for me, but windows are not getting restored to the same positions. This seems to be independent of the
splitright
setting.STR
nvim a.txt
:vsp
:e b.txt
:q
:Undoquit
Expected: window restores as it was
Actual: window restore, but swapped with the other split
I'm also seeing issues such as:
:vsp
, then:sp
, if I close the original window (the one that wasn't split by:sp
) and then restore, it re-splits horizontally instead of vertically.