calculator
calculator copied to clipboard
Copy/pasting a long formula in chunks, and in whole, give different results
Consider the following multiline sum in a document, simplified for purposes of easy to repro. (The real numbers were longer.)
1 +2 -3
+4 +5 +6
and the same sum but written on a single line
1 +2 -3 +4 +5 +6
Describe the bug
I was very surprised to realize the results of copy-pasting the first formula, one line-at-a-time, and then hitting =
is different from the result of copy-pasting it both-lines-together, or copy-pasting the single-line version all in one shot.
Steps To Reproduce
- Standard mode [Edit: also the same issue reproduces for me in scientific mode which it is the other main mode I find useful]
- Copy text
1 +2 -3
onto your clipboard from another app - Paste into calculator with Ctrl+V
- Copy text
+4 +5 +6
onto your clipboard from another app - Paste into calculator with Ctrl+V
Observed result:
Calculator shows the sum it has computed to be 1 + 2 - 4 + 5 + 6, resulting in 10 (the 'wrong' answer)
Expected result:
Calculator should have shown the sum it has computed to be 1 + 2 - 3 + 4 + 5 + 6, resulting in 15!
Impact:
Took quite a while to figure out why calculator kept giving me the wrong answer! I'm lucky that for me it was obviously wrong. If it wasn't obvious I might not have even realized and just believed the wrong number.
Screenshots
Device and Application Information
- OS Build: 10.0.19042.0
- Architecture: X64
- Application Version: 10.2005.23.0 also repros in 10.2012.21.0
- Region: en-US
- Dev Version Installed: False
I'm just reporting this problem. I don't want to fix it.
This is your friendly Microsoft Issue Bot. I've seen this issue come in and have gone to tell a human about it.
This is your friendly Microsoft Issue Bot. I've seen this issue come in and have gone to tell a human about it.
I want to work on this issue. Please assign it to me
Took a closer look to see what is happening. When you paste 1 +2 -3
into Calculator with Ctrl+V, you are left with an "uncommitted operation" (the "3" is lingering there, but you have not submitted it by hitting enter).
When you paste in +4 +5 +6
, it is replacing the 3 with the new string, but it also appears to be dropping the leading "+". This issue only appears to occur on paste, if you were to copy in 1 +2 -3
and then enter a "+" with the keyboard before pasting in +4 +5 +6
, the expression is evaluated as expected.
I suspect the fix here is to ensure that we are treating the leading "+" as an operator and not a sign, but not sure how that might affect pasting in positive/negative numbers.
Took a closer look to see what is happening. When you paste
1 +2 -3
into Calculator with Ctrl+V, you are left with an "uncommitted operation" (the "3" is lingering there, but you have not submitted it by hitting enter).When you paste in
+4 +5 +6
, it is replacing the 3 with the new string, but it also appears to be dropping the leading "+". This issue only appears to occur on paste, if you were to copy in1 +2 -3
and then enter a "+" with the keyboard before pasting in+4 +5 +6
, the expression is evaluated as expected.I suspect the fix here is to ensure that we are treating the leading "+" as an operator and not a sign, but not sure how that might affect pasting in positive/negative numbers.
Assign me so that I can look forward for this issue.
Thanks, @Ayushsunny! There is a technical limitation preventing us from assigning issues to community members, which is really unfortunate, but if you want to take look at this, it is all yours.
Thanks, @Ayushsunny! There is a technical limitation preventing us from assigning issues to community members, which is really unfortunate, but if you want to take look at this, it is all yours.
Ohh.. I thought Open source is for non-community members. So that anybody can contribute to the org. Anyway I'm looking into the issue and please help me if i'll get stuck somewhere
I thought Open source is for non-community members.
Oh, it is! And it appears we now can assign issues to team members outside of our immediate team! When we have tried in the past, it would not show community members in the assignment dropdown.
Hello Sir @grochocki can you help me to find out the code-base of this issue.
@tian-lt may be able to help point you in the right direction here
Hi @Ayushsunny,
If you are getting started on working this issue, I'd recommend you to take a look at StandardCalculatorViewModel::OnPasteCommand()
and StandardCalculatorViewModel::OnPaste()
.
The basic logic is that the ViewModel parses the input string pasted from the Clipboard, and then simulate the typing actions to send the corresponding commands to CalcEngine.