Bug 464234 - Left-clicking in history pane messes up subsequent formatting
Summary: Left-clicking in history pane messes up subsequent formatting
Status: RESOLVED FIXED
Alias: None
Product: kcalc
Classification: Applications
Component: general (show other bugs)
Version: 21.12.3
Platform: Kubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: shenlebantongying
URL:
Keywords:
: 452061 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-01-13 12:11 UTC by Rickard Westman
Modified: 2023-02-01 14:46 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 23.04
Sentry Crash Report:


Attachments
Screenshot showing garbled history output (40.02 KB, image/png)
2023-01-13 12:11 UTC, Rickard Westman
Details
KCalc history with line breaks between calculations (135.74 KB, image/png)
2023-01-29 20:33 UTC, kroot001
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rickard Westman 2023-01-13 12:11:27 UTC
Created attachment 155257 [details]
Screenshot showing garbled history output

SUMMARY

If you click the left mouse button in the history pane, subsequent calculations are not inserted cleanly at the top anymore, but intermingled with old calculations.

STEPS TO REPRODUCE
1. Ensure history pane is enabled.
2. Calculate 1+2 (calculation shows up in history)
3. Left-click somewhere below "1 + 2 = 3" in the history pane.
4. Calculate 3*4

OBSERVED RESULT

History now shows one line: "3 x 4 = 121 + 2 = 3"

EXPECTED RESULT

History should show two separate lines: "3 x 4 = 12" and "1 + 2 = 3".

SOFTWARE/OS VERSIONS

Linux/KDE Plasma: Kubuntu 22.04
KDE Plasma Version: 5.24.7
KDE Frameworks Version: 5.92.0
Qt Version: 5.15.3

ADDITIONAL INFORMATION

The bad effect is delayed and might therefore not be associated with the click (Bug 452061, closed with status RESOLVED WORKSFORME, is probably an example of this bug). 

Possible reasons why the user might click in the pane: 1) Wanting to focus the entire window (click-to-focus) and choosing the history pane as it's a large and seemingly passive area.  2) Wanting to select some older result for copy & paste.  3) Exploring possibly hidden functionality in the history pane (that's how I ran into it).
Comment 1 shenlebantongying 2023-01-22 01:38:32 UTC
I can confirm this bug exists, but it looks so weird. What changed after the history panel got clicked?
Comment 2 shenlebantongying 2023-01-22 08:10:54 UTC
*** Bug 452061 has been marked as a duplicate of this bug. ***
Comment 3 kroot001 2023-01-29 20:33:41 UTC
Created attachment 155771 [details]
KCalc history with line breaks between calculations

Thank you! This has been bugging me for some time but could not locate what caused the behavior. 

I played around with it and it looks like the line break is inserted where the user last clicked in the history pane and the calculation add to the top. I was able to insert line breaks in between previous calculations this way.
Comment 4 shenlebantongying 2023-01-29 20:43:02 UTC
I proposed a fix last week, but nobody seems to have time to review it yet,

https://invent.kde.org/utilities/kcalc/-/merge_requests/55
Comment 5 kroot001 2023-01-31 00:10:27 UTC
(In reply to shenlebantongying from comment #4)
> I proposed a fix last week, but nobody seems to have time to review it yet,
> 
> https://invent.kde.org/utilities/kcalc/-/merge_requests/55

For what it's worth, I tested your fix locally and it has resolved the issue.
Comment 6 Joshua Goins 2023-01-31 13:03:03 UTC
Git commit b45de2be468b74aa2d47583caf3801a52fa6bfaa by Joshua Goins, on behalf of shenleban tongying.
Committed on 31/01/2023 at 12:51.
Pushed by redstrate into branch 'master'.

fix: insert new contents to correct locations

Co-authored-by: Joshua Goins <josh@redstrate.com>

M  +11   -0    kcalchistory.cpp

https://invent.kde.org/utilities/kcalc/commit/b45de2be468b74aa2d47583caf3801a52fa6bfaa