-
-
Notifications
You must be signed in to change notification settings - Fork 702
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Refactor Constraint System #4021
base: main
Are you sure you want to change the base?
Conversation
Might have to rule out I'll look a little more, since it would be nice to not be stuck on super low-level code that's gone untouched / unmaintained for 7 years, but it might be the only thing reasonable for now. |
Either way, it's probably worth adding a blog-style visual explanation of the algorithm to the docs — especially if it's tree-free, since that's rather unusual. |
Or maybe For @imsnif , is my ancient understanding here correct? We wanted to avoid anything tree-based so that you can take this: Without issue? But as I understood back then, layouts were still written as trees / nested panes? Either way, if we want the above, I think you're right we need to do things without trees! |
If I wrap
And as a note to myself, I can resurrect that old graphical testing program I used to develop this resizer initially — that way I can quickly and graphically play with the algorithm, then drop it into For @imsnif: Do 100% of resizes, new panes, pane removals, etc go through this code currently? I think the best way to prevent bugs would be only ever changing those |
And finally, just so I can just have everything documented here for future me, does this seem like a bug related to this pane-resizing code? Pane.Layout.Bug.mp4It looks like it's moving from "Vertical" to "Stacked" mode, which is indeed new to me, so perhaps this is intended behavior? |
You are right about the trees or lack thereof! It's important to note that a lot has changed in the code (both code-wise and feature-wise). We now have swap layouts (https://zellij.dev/documentation/swap-layouts.html) which dictate how new panes are added and what happens when they are removed. After setting them we still go through the constraint system for reasons that escape me at the moment (I think some state gets borked otherwise). One can "break out" of a swap layout by resizing a pane (in that case Zellij figures out you want to do your own thing and lets you). The I think the path of least resistance would be simplifying Makes sense? |
Also, as an addition - I think most of the resizing errors will go away if the system does a "snap to grid" sort of thing. Like, when resizing a pane up, the system looks at its neighboring panes to the right/left and tries to get it to align if possible (even if it means resizing less - but not more - than the requested amount). By observation, most of the issues happen when a previous resize left the panes in a state where one is slightly protruding. If this makes sense? |
I'll respond to more properly later, but I do think it's important, if anything, to go the other direction with percentages and make more things (everything non-fixed?) use them? I think that's the only way to crunch the terminal down to a smaller size, have it look sane, then blow it back up to the original size and have it look like it originally did? Because the floating panes don't seem to go through the resizer like you said, they (after being resized, to break out of the layout stuff, I think?) break things a bit on smaller terminal sizes: Floating.Resize.mp4A realistic context for this sort of issue is moving from a larger docked monitor, back to a smaller laptop screen when traveling. But, looking at the rounding code you linked me (https://github.com/zellij-org/zellij/blob/main/zellij-server/src/panes/tiled_panes/mod.rs#L1464), I can see how just resizing by a given percentage isn't a great API for your end. If this new It would at least mean that that rounding code is no longer needed, I think, since you could be sure that every resize actually changes the size of the pane, and if all resizing was done through this code-path, it could also implement that snapping you've mentioned — if you're about to resize a pane so it passes that snapping point, it just shortens the resize to snap to that grid point instead? |
And final question for @imsnif for now: just so I understand the scope, are tiled, stacked, and floating panes all of the types currently? Are there any other types that you'd want to add in the near future? |
Yes, and not that I can think of respectively. :)
I think this is one of the bugs that I was talking about. This happens after the constraint system fails to resize, right? Maybe with the "run out of room for spans" error? I'm pretty sure this is an integration error I made with the system when introducing stacked panes.
Theoretically yes. However, do note that what you're talking about seems like a huge undertaking. There are many small, subtle and untested parts of the code that perform resizes. There are also issues with sizes being assigned as percentages without an "inner" and the "inner" being assigned somewhere else down the line, creating races and nasty bugs that are fixed in a patchwork fashion. I can point you in the general direction of these, but I will certainly not manage to find them all. I heartily recommend you think of smaller, simpler and not all-encompassing changes here. And whichever direction you decide to take this, please also think of the maintenance that will be required for this direction in the years to come. |
My guess is that |
Just a draft PR so @imsnif can keep on eye on the trouble I'm causing.
Look intoLike the web, is tree-based, so doesn't fit our needstaffy
— will that make this a lot easier?good_lp
/microlp
? (and call it something fantastic likerectesselate
)PaneResizer
) doesn't operate on the panes themselves, but rather receives a list ofPaneGeoms
tied to pane ids and then sends back a list of those changed geoms to be mutated by whoever called it. This would be great because then it'll allow me to recover from whichever errors this system might have in whichever place in the code I place it.