-
Notifications
You must be signed in to change notification settings - Fork 243
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
fix(table): use table height #358
Merged
bashbunni
merged 13 commits into
charmbracelet:master
from
Broderick-Westrope:fix/issue-356-use-table-height
Sep 14, 2024
Merged
fix(table): use table height #358
bashbunni
merged 13 commits into
charmbracelet:master
from
Broderick-Westrope:fix/issue-356-use-table-height
Sep 14, 2024
+236
−18
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This will remove excess rows. This does not affect the height that is set by headers, borders, etc.
…roderick-Westrope/lipgloss into fix/issue-356-use-table-height
@bashbunni hoping to close this one out. Any feedback or blockers? |
bashbunni
approved these changes
Sep 14, 2024
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.
Hey this looks great. Thank you so much for the very thorough work and tests! This was really quick to review as a result 🙏
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #356
Changes
table/table.go
: Modified theconstructRow
method to accept anisOverflow
parameter, allowing rows to be rendered as overflow rows with ellipsis when necessary.table/table.go
: Updated theString
method to calculate the available height for rendering rows and handle the rendering of overflow rows correctly. Most of this lives in the newconstructRows
method.table/table_test.go
: Added unit tests for theHeight
method.table/table.go
: Added a booleanuseManualHeight
to theTable
struct. I thought it would be good to maintain the existing functionality (auto table height) by default. I've put this in one commit so it can be easily removed if needed. TheuseManualHeight
boolean tracks whether the user has manually set the height of the table. Whenfalse
, the new height functionality will not be used. It isfalse
by default and only set totrue
when the height is set (table.Height(x)
).New
call to have a correspondingHeight
call. With this feature, height is flexible and calculated for you by default.height == -1
represents auto height. Not sure what is preferred.How Height is Used
The default behaviour is the same as before, now there's just a few more features:
New
without callingHeight
will render the full table (despite theTable.height
value being 0). Example: the following table technically has a height of 0, but the user did not set that so we assume they want to show the whole table:NOTE: When the following examples say "set a height" they mean make a call to the
table.Height
methodNotes