-
Notifications
You must be signed in to change notification settings - Fork 7
update width calculations #48
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
Conversation
@tertsdiepraam here is the MR I was talking about. And to update |
Uh oh, looks like I was just touching the same code 😄 I'll look at this tomorrow. |
I'm frankly amazed this works for |
It calculates the number of possible columns first using the terminal width and widest possible cell content. I thought it's more relevant, since both of the values are given and it can be the "worst" case scenario e.g. all names are the size of widest. Then it tries to increase the number of columns and see if the
If you can come up with some edge cases I didn't think about it would be great, thx |
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.
Right! I've looked much more into this now and I think I have a better grasp of what you've done. In short: it's fantastic! However, it does need a lot of improvements in terms of variable names and comments. I've got a commit where I was doing that for myself, so with your permission I'd like to push that to this branch. I also included more tests.
There are some other issues. The is_complete
and width
functions are now broken because columns can now have 0 widths in some columns for TopToBottom
. We should investigate whether uutils and eza
use those (I don't think so), so we can remove them.
I think you've also solved #39, because you're assuming balanced columns. Which seems to match what GNU is doing:
> ls --width=6
aaa
bbb
ccc
d
In current uutils-term-grid, this would be printed as
aaa d
bbb
ccc
But that is unbalanced and kind of ugly. The reason I suppose that this was done in the first place is that it is technically "more optimal" in terms of line count.
All in all, consider me impressed! Do I have your permission to push to this branch?
@tertsdiepraam Yeah, sure. If you need to push something, you are more than welcome to |
Whoo it finally works. For some reason git had a really hard time pushing to this branch. It's mostly updating some names and comments.
I set a maximum number of columns of |
There's actually another algorithm I was thinking of for the Basically we can just start building the first row until we hit the maximum width. This gives us a pretty good maximum number of columns. Then we just decrease the number of columns and calculate the dimensions each time until we find the first one that fits. For the |
I'm using
I think this one can be tricky with edge cases. We can definitely try this approach to see if it will be more efficient than the one with using the max width.
Actually I was also thinking in this direction, to split the computations for every direction. It will grand more flexibility on improving individual parts, instead of coming up with something common for everything. Plus, there was a request to add |
I have an idea to improve
I think (but have to check) that this will skip possibilities that lead to empty columns at the end |
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.
Merging so we can make a new branch for splitting it up!
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #48 +/- ##
==========================
==========================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Closes #6
I was trying to improve performance in grid calculation and switch from rows to columns to fix the related issue