-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Truncate statusline widgets #10087
Truncate statusline widgets #10087
Conversation
We should fix this with some expediency if we want to release it this month. I think this needs to be smarter and match the old behaviour more closely: a long filename shouldn't simply vanish off the statusline, it should be truncated to maximum possible width. |
That could be done in one of two ways:
We also have to decide what to do in case multiple sides overflow. If left and center would fit but right will overflow, what then? Currently we hide both center and right entirely, again hiding info we shouldn't. Should we try to truncate right in that case? |
Yeah the old system didn't handle these cases particularly well either. I like what you propose in general but I think providing a maximum width to elements won't work since you can't know ahead of time whether the size is exceeded (or what the maximum size of an element would be). We would probably need to just need to render twice: One to figure out the width. Of zhere is enough width bothing happens. Then we first try to remove empty spacing, if that doesn't work I would go right to left and try to truncste elements to their preffered width (rendering them again with truncate=remaining_space_to_truncste) the filepath, would just insert an elipsis bit try to keep the filename intact (unless the filename is longer than day 10 charactes). If that still doesn't work then we would drop elements from right to left until there is enough space |
Yeah, what you describe is roughly how both Flutter and the current gutter implementation does it. A build step grabs the info from Here's a rough example of a resulting tree following the Flutter analogy:
Each widget could indicate how much space they would take given a size constraint ( Of course figuring out the details for this would take way longer than we have until the next release so for here's an idea:
|
I wonder if we should just lean on the existing |
I keep forgetting that exists :D But yeah that is the same direction I was suggestion. Make the statusline components return somekind of constraint first, solve the size for each component and then make each component render with the max size given to them and figure out what to do when there isn't enough space |
Turns out this is a very deep rabbit hole, that I unfortunately don't have time to explore these days. I'll cook up a rough solution by tomorrow based on the outline below, and leave integrating
I couldn't think of a simpler way that wouldn't unnecessarily hide information. If this is too much the current commit in the PR is a lot simpler and fixes the linked issue but hides a lot of widgets that could otherwise be shown. |
Since we're close to a release and I don't want to cut more fix releases afterwards I'm leaning towards reverting the implementation in master and waiting until the changes are fully fleshed out and tested. The original change was a refactor anyway so we're not losing any features by doing so. |
Reverted in #10642, not tested yet. |
Closes #10078.
Keeping PR as draft as the current solution while technically fixes #10078 it is incomplete nonetheless. For example, it would not fix the right side overflowing.
The current fix simply discards the last few elements from
statusline.left
until the remaining widgets can be fully rendered.The center and right sections are still hidden, though. I'll try to make it show as many widgets as possible, then open the PR for merging.
The issue is that a smarter layout strategy is required, that can reconcile which widgets to render given the constraints.
The current mess of if-else statements have proven to be inadequate, and I apologize for that.
A long-term solution could take a leaf out of Flutter's book, where the status line would be broken up into sub-widgets and layout widgets. The render function could then reconcile the constraints against each child widget:
This worked out pretty well for flutter and requires no backtracking (like we sorta need to with the current implementation). As a matter of fact, View already does something similar with gutters.