feat(calculator): live expression on top line, paste into expression line#3
Merged
Merged
Conversation
…line - Top expression line now shows the full typed expression including the current operand, e.g. (2+3)^4*4 — was previously only the committed chain (so the in-progress operand was missing while typing) - Bottom result line shows a live partial-evaluation result on every keystroke; falls back to the current operand when the partial is not yet valid (half-open bracket, trailing operator) - Pasting a full expression directly into the small top expression line now evaluates immediately — previously the handler appended the pasted text onto the rendered "0", producing "0(2+3)^4*4" → Error - commitExprEdit() dedupes against the latest history entry, so the post-paste blur no longer creates a duplicate history row
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.
Summary
Two visible behaviour fixes to the Tools → Calculator template:
Live expression on the top line. While typing
(2+3)^4*4, every keystroke now appears on the small top expression line — the in-progress operand was previously missing becauseshow()only rendered the committed chain. The big bottom line continues to show a live partial-evaluation running total.Paste into the top line works. Pasting
(2+3)^4*4directly onto the small expression line used to concatenate onto the rendered"0", producing"0(2+3)^4*4"→Error. The paste handler now routes clipboard text straight intoapplyPasted(same code path as paste-into-result), evaluating instantly with no follow-up Enter/blur.Blur dedupe.
commitExprEditearly-returns when the line already matches the latest history entry, so the post-paste blur doesn't create a duplicate history row.Test plan
(2+3)^4*4keystroke by keystroke → top line builds up the full expression on every press; bottom shows live partial results (5, then625, then2500) once each sub-expression is evaluable=→ top becomes(2+3)^4*4 =, bottom becomes2500, single history row created(2+3)^4*4onto the small expression line → top(2+3)^4*4 =, bottom2500immediately100/(4+1)onto the big result line → top100/(4+1) =, bottom201,234 × 5(whitespace + comma + unicode×) → normalised to1234*5, evaluates6170alert(1)→ topalert(1) =, bottomError(still blocked by strict allowlist)🤖 Generated with Claude Code