fix: Fix column width calculation logic in grid#2370
fix: Fix column width calculation logic in grid#2370ericlln merged 10 commits intodeephaven:mainfrom
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2370 +/- ##
==========================================
+ Coverage 46.80% 46.81% +0.01%
==========================================
Files 710 710
Lines 39224 39243 +19
Branches 9789 9796 +7
==========================================
+ Hits 18357 18370 +13
- Misses 20856 20862 +6
Partials 11 11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| charWidths.set(char, charWidth); | ||
| width += charWidth; | ||
| if (!charWidths.has(char)) { | ||
| context.font = font; |
There was a problem hiding this comment.
We should just set the font at the start of this method... Interesting that we weren't setting the font before this change, I wonder if that caused any issues.
There was a problem hiding this comment.
Yup missing that initially definitely caused issues and the header text width was not being calculated correctly as a result. Since the header font and cell font only differ slightly, it wasn’t able to be noticed visually. Again, it would be nice to be able to catch something like this through testing.
There was a problem hiding this comment.
Curious why we aren't just measuring the text with a cache like we already do in GridRenderer to determine if it needs to be truncated. I guess in theory this should reduce the number of measureText calls in the metric calculator (we will still measure the whole string in GridRenderer and might be faster if the values are constantly different where the cache isn't much help.
We could add a measured text cache to GridMetrics which is then accessible by GridRenderer and avoid double measuring the whole string. But that would be a separate ticket
GridRenderer.binaryTruncateToWidth()as the measured text width with can differ slightly from the passed in estimated column width. This will prevent cases where text is truncated when it shouldn't be.Stocks table for testing: