Repository navigation
fix(lsp): count transactions, not postings, in account summaries - #2862
Merged
Merged
Conversation
Account completion, the inlay-hint tooltip and the `open` code lens counted every posting to the account, so one transaction with two postings to it showed as `2 transactions` / `2 txns`. Each transaction now counts once per account, and the labels use `count_noun`, so a single one reads `1 transaction` / `1 txn`. Closes #2850 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
📊 Benchmark Results
vs base, measured in this run
A difference counts only when it clears the combined spread of the two measurements, per shape (2σ: What do these numbers mean?
|
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
…ift guard Review of #2862: completion resolve and the inlay tooltip repeated the count and balance loop, and the code lens used its own per-transaction set. All three now use `account_activity` / `transaction_accounts` in handlers/utils.rs, and a drift-guard test checks that the code lens, completion resolve and both helpers report the same count per account. The code-lens and tooltip tests assert exact strings, so `1 transactions` or `11 transactions` cannot pass. The CHANGELOG states that this fixes the count unit, not which transactions each surface counts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…the count notes The balance command kept its own copy of the per-currency sum; it now uses the shared helper. The CHANGELOG described completion as counting the ledger as written: with a ledger loaded it counts it after booking and plugins, and the tooltip adds pad-generated transactions (one more per pad). The currency completion read "1 postings". Co-Authored-By: Claude Opus 5.5 <[email protected]>
robcohen
enabled auto-merge (squash)
November 5, 2026 08:00
…ansaction-count # Conflicts: # CHANGELOG.md
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This was referenced Nov 5, 2026
This file contains hidden or 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
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.
What changed
Three LSP surfaces counted every posting to an account as a transaction:
completionItem/resolve): thedetail(30000 KRW · 2 txns) and the popup (2 transactions);opencode lens.Each transaction now counts once per account, however many of its postings touch it. The labels use the existing
count_nounhelper, so a single one reads1 transaction/1 txn.Why
The issue's fixture, one transaction with two postings to
Expenses:Supplies, showed2 txns. The count and its label now use the same unit (the issue's first option).How to test
cargo test -p rustledger-lsp --all-features. Three new tests, one per surface, use the issue's split-invoice transaction and assert1 transaction/1 txn:test_resolve_account_completion_counts_each_transaction_oncetest_inlay_hint_resolve_counts_each_transaction_oncetest_code_lens_counts_each_transaction_onceReview round 1
One shared rule:
account_activityinhandlers/utils.rsgives the count, units balance and date range, and completion resolve and the inlay tooltip both call it. The code lens tallies every account in one pass withtransaction_accounts, which applies the same rule. No copy of the counting loop is left.Drift guard:
test_code_lens_and_completion_resolve_agree_on_transaction_countschecks, for one buffer with split and mixed transactions, that the code lens and completion resolve report the same count for every account, and that both helpers agree.Exact assertions: the code-lens and tooltip tests assert exact strings (
1 transaction | KRW,📊 1 transaction), so1 transactionsor11 transactionscannot pass.Not changed: which transactions each surface counts. This PR fixes the count unit, not the set:
openinaccounts.beanshows "No transactions";Unifying them would mean the code lens reading the whole ledger, and completion resolve rebuilding the pad-expanded view on every resolve, which fires constantly while scrolling a completion list. The CHANGELOG states this.
Closes #2850
🤖 Generated with Claude Code