quadratic icon indicating copy to clipboard operation
quadratic copied to clipboard

Fit numbers

Open davidfig opened this issue 1 year ago • 1 comments

Change how numbers render. In Excel and Sheets, the numbers never overflow the cell. They either reduce their precision, change to scientific, or show up as ####. Fixes #1468.

Note, this is based on https://github.com/quadratichq/quadratic/pull/1406 (Ayush's branch, so we can't yet diff off it), which should merge before this one. The diffs will be extreme until that branch is merged.

  • [x] redo how CellValue::Number.to_display() works (removing formatting)
  • [x] keep some formatting within Rust (but outside the to_display function) so we can still search against what will likely be the displayed number
  • [x] move all number formatting from Rust to TS :( - this is necessary b/c we don't know how to stringify the number until we are actually rendering and can compare glyph sizes to the cell width
  • [x] move tests from Rust to TS for number rendering
  • [x] show #### when number overflows content
  • [ ] figure out when to change the display from number to scientific to show larger numbers in a smaller space

davidfig avatar Jul 05 '24 22:07 davidfig

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
quadratic ✅ Ready (Inspect) Visit Preview Jul 30, 2024 6:11pm

vercel[bot] avatar Jul 05 '24 22:07 vercel[bot]

Codecov Report

Attention: Patch coverage is 94.84634% with 109 lines in your changes missing coverage. Please review.

Project coverage is 90.00%. Comparing base (0cbf5c2) to head (4c8fdd2).

Files Patch % Lines
quadratic-core/src/grid/file/current.rs 42.85% 44 Missing :warning:
quadratic-core/src/grid/formatting.rs 30.00% 14 Missing :warning:
quadratic-core/src/values/cellvalue.rs 82.60% 8 Missing :warning:
...dratic-core/src/controller/operations/operation.rs 0.00% 7 Missing :warning:
quadratic-core/src/grid/js_types.rs 86.00% 7 Missing :warning:
...tic-core/src/controller/active_transactions/mod.rs 84.00% 4 Missing :warning:
...rc/controller/execution/auto_resize_row_heights.rs 99.32% 4 Missing :warning:
...ratic-core/src/controller/operations/formatting.rs 0.00% 4 Missing :warning:
quadratic-core/src/grid/sheet.rs 92.72% 4 Missing :warning:
...ler/execution/execute_operation/execute_offsets.rs 96.29% 3 Missing :warning:
... and 6 more
Additional details and impacted files
@@            Coverage Diff             @@
##               qa    #1526      +/-   ##
==========================================
+ Coverage   89.82%   90.00%   +0.18%     
==========================================
  Files         185      188       +3     
  Lines       35092    36254    +1162     
==========================================
+ Hits        31520    32629    +1109     
- Misses       3572     3625      +53     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jul 10 '24 20:07 codecov[bot]

@AyushAgrawal-A2 I noticed that when vertically centered, the text alignment is a bit off when shrunk to its minimum. See image below. The vertically centered one should look like the normal one at that size. (The "hello" is the one with the vertical settings.)

Screenshot 2024-07-20 at 6 03 00 AM

davidfig avatar Jul 20 '24 13:07 davidfig

@davidfig This branch is missing some of the commit, where I restructured code and added tests Last commit from me here is cleanup css a08a23f

Following commits are missing, which should fix code coverage as well image

AyushAgrawal-A2 avatar Jul 20 '24 13:07 AyushAgrawal-A2

Good catch. I'll cherry pick the changes.

davidfig avatar Jul 20 '24 13:07 davidfig

I cherry picked the changes. There are a few failing tests. @AyushAgrawal-A2 can you take a look? The failures are probably my fault, but I don't understand the code well enough to fix it.

Not sure if you can make changes to this PR. If not, create a new one and I'll merge it into this one.

Retrospectively, it would have been easier to keep these separate :)

davidfig avatar Jul 20 '24 14:07 davidfig

@AyushAgrawal-A2 I noticed that when vertically centered, the text alignment is a bit off when shrunk to its minimum. See image below. The vertically centered one should look like the normal one at that size. (The "hello" is the one with the vertical settings.)

Screenshot 2024-07-20 at 6 03 00 AM

@davidfig this happens because there is extra space to account for textureHeight of different characters if textureHeight of all characters in string is less than cell height, then vertical align has room to slight move it image

AyushAgrawal-A2 avatar Jul 20 '24 17:07 AyushAgrawal-A2

I cherry picked the changes. There are a few failing tests. @AyushAgrawal-A2 can you take a look? The failures are probably my fault, but I don't understand the code well enough to fix it.

Not sure if you can make changes to this PR. If not, create a new one and I'll merge it into this one.

@davidfig I have raised a pr to fix bugs #1574 Please generate code coverage report also after merging it.

AyushAgrawal-A2 avatar Jul 20 '24 17:07 AyushAgrawal-A2

Code coverage looks good!

davidfig avatar Jul 21 '24 13:07 davidfig

@jimniels I have raised a PR #1581 having both these changes for floating context menu.

AyushAgrawal-A2 avatar Jul 22 '24 20:07 AyushAgrawal-A2

@davidfig

Precision is displayed as 0s for a number larger than the default column with (see image)

can you please take a look at this part

AyushAgrawal-A2 avatar Jul 23 '24 00:07 AyushAgrawal-A2

Large numbers have better precision:

Screenshot 2024-07-23 at 4 41 18 AM

davidfig avatar Jul 23 '24 11:07 davidfig

Noticing

  • For some reason, the Python cell reference here is not updating the other cells.
  • There is a flashy glitchy looking re render when updating array outputs Both are shown in this video

https://github.com/user-attachments/assets/242a1d40-4c96-4ba6-9e85-7012ea306f79

davidkircos avatar Jul 24 '24 04:07 davidkircos

@davidkircos Fixed above bugs.

Multiple async operations were not able to run in a single transaction as the same boolean flag has_async was used to flag a async operation in transaction. First async call that finishes would remove that flag and end the transaction.

Now has_async is a counter.

AyushAgrawal-A2 avatar Jul 24 '24 20:07 AyushAgrawal-A2

Can you add tests for the multiple async. Any problems with the counter?

davidfig avatar Jul 24 '24 23:07 davidfig

Can you add tests for the multiple async. Any problems with the counter?

@davidfig done

AyushAgrawal-A2 avatar Jul 25 '24 22:07 AyushAgrawal-A2

Bolding text and reloading is not preserved

@davidkircos fixed another bug due to change in async transaction. I was updating the transaction clone but not saving it back in aync transactions.

AyushAgrawal-A2 avatar Jul 30 '24 17:07 AyushAgrawal-A2