-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
feat: separate layout items with spaces #91
Conversation
Thank you @joshmedeski |
Sure thing! |
The way the tests are written make it hard to debug. I recommend moving away from a for loop for tests so when a test fails you get immediate feedback and a proper line number for what test failed. |
Each test in the for loop is a sub test. You can run a single sub test with |
I'm wondering if this should be a flag that doesn't cause a breaking change to the way everything is rendered now? (like Let me know your thoughts. |
Yep this might be needed if the change is too important. Let me think about it |
I got the tests working and I got the feature working to the best of my ability for now. But if someone doesn't like having the trailing spaces between each layout component we'll have to write more code to handle that. |
What's the difference between adding spaces manually in the For example, this is the default layout: [branch, remote-branch, divergence, "- ", flags] This is the one I've been using: layout: [branch, ' ', remote-branch, divergence, ' - ', flags, ' ', stats] |
So in your second example, when divergence, flags, and / or stats have nothing to show. You end up with extra white spaces in the tmux status bar (see the screenshots from the issue). I'd rather trim the whitespace if there's nothing to render. |
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.
@joshmedeski
Hey thanks for the feature and the pull-request. It really makes sense.
I had a look at the code and I thought there was a much simpler way to do it, but it required a refactoring of how gitmux components are handled. The gist of it is that every function that computes a gitmux component returns a string.
The format() function is the one that puts it all together by adding spacing between components, but only when they're not empty or else we'd end up with 2 (or more depending on the cases) consecutive spaces. This logic can only be done cleanly and correctly in the tmux/Formatter.format
function.
So I went ahead and did it on top of your pull-request.
@joshmedeski I've tagged a new release with both your pull-requests (v0.10.0) |
That makes more sense. This was my first time in the codebase so I'm starting to get my way around. I had the same idea later on to move this logic in the place that chains the layout components together, thanks for doing it! |
Sure, no worries. You did a great job 🎉 |
Exactly |
Ah i think I got it. I think you mean a trailing space, in case anything was rendered. That's a particular case though. Majority of people, myself included, do not have anything after gitmux status shown on their tmux status bar. |
Fair point, so my tmux status is It's a little tricky. Maybe I can add a Hope all that makes sense. |
That seems a little specific to your use case to be honest I think you might be able to do that with the help of a simple script, called instead of gitmux, from your tmux.conf, and depending on whether gitmux string is empty, you add a trailing space or not. It's not that I'm against that feature or anything, but I need to set the bar for features everybody can benefit from. sorry. |
I implemented the feature, see #94 This is a non-breaking change but is very useful for people who want to place gitmux between other elements in their tmux status bar. Hopefully you find it not too invasive and decide to merge it. |
Fixes #90
Purpose
Adds a space at the end of every layout component.
Approach