This repository has been archived by the owner on Aug 6, 2023. It is now read-only.
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.
Description
This is an initial fix for issue #470.
After walking through one of the cases that caused the panic in a debugger, I found that it was due to a miscalculation (it seems like a rounding issue) in the column widths from the
cassowary
solver. I don't fully understand the parameters for this solver and as such I didn't feel comfortable trying to implement a fix into theget_column_widths
function. Changing the solver also seems to have potential knock-on effects in how all tables are rendered, which sounds like a disruptive change.So, I tried to make a minimal fix by simply checking for overflow in the
set_style
function and clamping the value if there would have been an overflow.I'm not exactly sure if this is a completely robust solution, but it seems to work for the two test cases we have so far.
@fdehau would love your thoughts on how robust of a fix this is!
Testing guidelines
I added the two example tables that were causing a panic from the issue in
widgets_table_columns_dont_panic
test function. All this test does is render the tables and ensures a panic doesn't occur. It doesn't verify the output of the table.Checklist