-
-
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
Consistent statusline spacing #7310
Conversation
ef9d76a
to
1c3a8b0
Compare
At first look one thing that this changes that we probably shouldn't is it removes padding around the edges in the default config which imo we should keep especially looks bad when |
@gabydd Regarding |
Ah right, I only noticed this because I don't use color-modes. Removing the option is probably a good idea in the long run though. |
I am not sure if we need the |
Sorry for disappearing, had a busy couple of weeks. Checking the responses right now. |
I originally didn't have padding in Padding the statusbar edges could be done by changing the default config to include |
A couple examples:
|
Generally I would prefer explicit spacers since it allows different spacing between different elements without adding a ton new config options. I don't think that the spacing inside of elements needs to be configurable. We are shooting for a mininal config file. |
You are free to leave |
8e8d860
to
51dedf3
Compare
51dedf3
to
1a0ad99
Compare
we are very conservative with regards to adding new config options and this doens' cross the bar for me. The rest of the PR is probably a nice improvement but I don't see us adding this config option |
While I personally disagree, I've removed the option so we can move on. At least that solved the documentation wording problem. We can revisit this in a later PR. |
I believe the only two remaining issues are the spacing of the mode indicator and the spinner. The spinner discussion is happening in the review. I don't like the idea of hardcoding spacers on the edges, in my opinion modifying the default config to include spacers would be more flexible. But regardless of how the padding is handled, it would look weird the color modes option turned on. If we go with the hardcoded route, we could omit adding spacers where the mode indicator is the first/last item and color modes are enabled. But this feels like a hack. If we go with the modified default config, we could add/omit the spacer depending on whether we enable color modes by default, then expect people to add/remove the spacer manually if they change the color modes option. On a similar note, right now padding is automatically added to the mode indicator when color-modes are on, but that could also be removed if we expect people to modify the mode names to include spaces when they toggle color modes. Thoughts? |
I have removed the auto-padding from the
|
Yeah I agree with that. I think hardcoded padding is never a good idea and changing the modenames is a pretty good workaround IMO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is very hard to review right now because you changed the order of some.functions (and in general have included some unnecessary changes) sk the diff is pretty clobbered right now.
Could you undo that so it's easier for us to see what's actually changed
Also I am not really sure if we really want the implhct spacer between each element. I actually lprefer having no implicit spacer at all and instead including the necessary specaers in the default config. This offers the most flexibility and is the easiet to implement |
Since some elements only appear occasionally (such as Example:
vs
|
I'll clean up the commit history on the weekend. |
4d8bf16
to
d920bb5
Compare
Okay, I've removed all additions to
Right now there is no spacing interspersed as Will address that later. |
d920bb5
to
2680143
Compare
Added back automatic interspersing of spaces. Does not pad the sides of the panel, those should be done in config. Uses a custom interspersing iterator until As for the spinner, I think simply hiding it is the most consistent behavior with other auto-hiding elements like |
The only thing remaining to tweak in my opinion is the default config. After that I'll reopen the PR. On the left section:
On the right section:
|
Added spacers to the default config to pad the statusline on the edges, with the assumption that People who want to enable it and have it look good will have to:
Debating whether this should be documented. The intersperse implementation still needs a better place, but I think it's OK to reopen the PR by this point. |
4ce242d
to
e54391a
Compare
e54391a
to
f661c0c
Compare
I was thinking about It would still look better for people who turn the feature off than it does now when people turn it on without the tweaks. |
86f8538
to
1491768
Compare
1491768
to
de7776b
Compare
Looks like If this is a problem I can revert the last commit, before which a hand-rolled solution was used add spacers between statusline elements. |
I would like to avoid itertools if possible - it's a fair amount of code to add for things that can usually be written inline. Here I think it's cleaner to use a helper function that returns Spans: fn join_with_spaces<'a, I: Iterator<Item = Span<'a>>>(iter: I) -> Spans<'a> {
let mut spans = Vec::new();
for elem in iter {
if !spans.is_empty() {
spans.push(Span::raw(" "));
}
spans.push(elem);
}
spans.into()
}
// ..
context.parts.left = join_with_spaces(
element_ids
.iter()
.map(|element_id| get_render_function(*element_id))
.flat_map(|render| render(context).0),
); |
6b275c6
to
759378d
Compare
Okay, I have reversed the inclusion and also replaced the hand-rolled interspersing iterator with your helper function. |
759378d
to
a862f1a
Compare
Debating whether to increase spacing between elements from one to two spaces. |
a862f1a
to
c63d3de
Compare
Increased spacing to two spaces, which actually looks closer to how spacing looked before the PR. |
Double spacing breaks consistency next to This PR became a mess, so I'm closing it and will make a new one with a smaller scope. EDIT: Superseded by #9122 |
Statusline elements used to have inconsistent spacing due to each element having to pad itself without knowledge of surrounding elements.
mode
,selections
,file-name
andposition
are padded, the rest are notfile-modification-indicator
reserves space for itself,spinner
anddiagnostics
do notThis PR fixes these spacing inconsistencies.
spacer
element has been repurposed to join multiple spacers, e.g. to pad the ends of the statuslineThe render functions of statusline elements previously used an ad-hoc
write
callback to blitSpans
directly to theSurface
of the statusline. This callback has been removed. Now each render function has to return theSpans
it wants to display, which the renderer of the statusline collects, intersperses with spaces, then blits to the surface.