fix: handle comma thousands separators in inlay hint amount parsing#839
fix: handle comma thousands separators in inlay hint amount parsing#839vqv wants to merge 1 commit intopolarmutex:mainfrom
Conversation
Decimal::from_str_exact() does not accept commas, so amounts like "19,987.73" failed to parse and were treated as missing — causing spurious implicit-posting inlay hints on balanced transactions. Strip commas from number strings before parsing in both extract_amount_from_node() and extract_compound_amount(). Closes polarmutex#750 (partially — the inlay hint portion)
|
Thanks for this fix — the root cause analysis is correct and the test coverage looks solid. The fix to strip commas before The CI run shows |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #839 +/- ##
==========================================
+ Coverage 80.88% 80.89% +0.01%
==========================================
Files 31 31
Lines 12502 12567 +65
==========================================
+ Hits 10112 10166 +54
- Misses 2390 2401 +11
🚀 New features to boost your workflow:
|
|
CI is nearly all green — all Rust tests pass. There is one failure in the VS Code Extension / Lint & format step: The pnpm run formator: pnpm exec prettier --write package.jsonThen commit and push. Once that's addressed and CI is fully green, this is ready to merge. |
141639b to
660b949
Compare
|
Removed the unrelated diagnosticFlags commit that was causing the lint failure. This PR is now focused on just the comma thousands separator fix. |
Summary
Fixes a bug where inlay hints showed spurious implicit postings on balanced transactions when one leg used comma thousands separators and the other didn't.
For example, this balanced transaction incorrectly showed an implicit posting hint:
Root cause:
Decimal::from_str_exact()does not accept commas, so amounts like19,987.73failed to parse and were treated asNone(missing amount) — triggering the implicit posting hint.Fix: Strip comma thousands separators from number strings before passing to
Decimal::from_str_exact()in bothextract_amount_from_node()andextract_compound_amount(). This matches beancount's own behavior, which only supports commas as thousands separators (not European-style period separators).Related to #750
Test plan
test_comma_thousands_separator_balanced— verifies no spurious hint on balanced transactions with comma-formatted amountstest_comma_thousands_separator_with_implicit_posting— verifies correct balancing calculation when one posting is implicit and the other uses commas