Bug 446189 - Arrow keys sometimes wrongly extend selection
Summary: Arrow keys sometimes wrongly extend selection
Status: RESOLVED FIXED
Alias: None
Product: frameworks-ktexteditor
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.88.0
Platform: Other Other
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-28 09:34 UTC by Kishore Gopalakrishnan
Modified: 2022-01-16 17:32 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kishore Gopalakrishnan 2021-11-28 09:34:50 UTC
SUMMARY
When a block of text is already selected, pressing the arrow keys sometimes unexpectedly extends the selection. This may cause the user to unintentionally overwrite or delete text.

STEPS TO REPRODUCE
1. Go to System Settings > Keyboard > Advanced (tab) > Compatibility Options and enable 'both Shift together enable caps lock'. Click 'Apply'.
2. Find a text file that contains long lines, and open it in Kate (we need a line long enough that it is displayed as, say, four lines)
3. Enable view > word wrap > dynamic word wrap
4. Put cursor in the middle of the first 'display line' of a very long line that is wrapped into at least four 'display lines'.
5. Shift+down arrow
6. Down arrow
7. Down arrow

OBSERVED RESULTS
After step 5, a block of text is selected.
In step 6, the cursor behaves as if shift is still being pressed (i.e. it still extends the selection even though the user is not pressing shift).
After step 7, the selection is discarded.

EXPECTED RESULTS
With step 5, shift+arrow selects a block of text.
The selection should be discarded at step 6 itself.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.23.3
KDE Frameworks Version: 5.88.0
Qt Version: 5.15.2
Kernel Version: 5.15.5-arch1-1 (64-bit)
Graphics Platform: X11
Processors: 8 × AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx
Memory: 21.5 GiB of RAM
Graphics Processor: AMD Radeon Vega 8 Graphics

ADDITIONAL INFORMATION
Same issue is reproducible in Kile, so I am reporting it under ktexteditor.
Comment 1 Kishore Gopalakrishnan 2021-12-18 16:39:17 UTC
Reverting this commit fixes the issue:

commit 5dce70a9693f8cce37f733b4687bb9b303376742
Author: Aleix Pol <aleixpol@kde.org>
Date:   Mon Sep 6 14:07:47 2021 +0200

    Do not cancel mouse selection when using the keyboard
    
    Instead follow through with the selection after the key was pressed.
    This applies to different actions like page up, page down, home, end, up
    and down.

 src/view/kateview.cpp         | 20 ++++++++++----------
 src/view/kateviewinternal.cpp |  5 +++++
 src/view/kateviewinternal.h   |  2 ++
 3 files changed, 17 insertions(+), 10 deletions(-)
Comment 2 Kishore Gopalakrishnan 2022-01-02 06:57:55 UTC
I can no longer reproduce this on KDE Neon Unstable, so I'll mark this as fixed.

SOFTWARE VERSIONS
Operating System: KDE neon Unstable Edition
KDE Plasma Version: 5.23.80
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.3
Kernel Version: 5.11.0-43-generic (64-bit)
Graphics Platform: X11
Processors: 2 × AMD EPYC-Rome Processor
Memory: 1.9 GiB of RAM
Graphics Processor: virgl
Comment 3 Kishore Gopalakrishnan 2022-01-16 05:19:44 UTC
(In reply to Kishore Gopalakrishnan from comment #2)
> I can no longer reproduce this on KDE Neon Unstable, so I'll mark this as
> fixed.
> 

Actually, the non-reproducibility turns out to have been because of bug 448377 (so step 1 of the reproduction steps I initially posted did not work). That bug is fixed in master, and so this bug is reproducible again. 

If you are using a version which still has bug 448377, you need to run `/usr/bin/setxkbmap -option shift:both_capslock` (in a terminal) instead of step 1.


REPRODUCIBLE ON
Operating System: Arch Linux
KDE Plasma Version: 5.23.90 (with a patch applied to plasma-desktop to fix bug 448377)
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.2
Kernel Version: 5.16.0-arch1-1 (64-bit)
Graphics Platform: X11
Processors: 8 × AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx
Memory: 21.5 GiB of RAM
Graphics Processor: AMD Radeon Vega 8 Graphics

AND

Operating System: KDE neon Unstable Edition (updated today)
KDE Plasma Version: 5.24.80
KDE Frameworks Version: 5.91.0
Qt Version: 5.15.3
Kernel Version: 5.11.0-46-generic (64-bit)
Graphics Platform: X11
Processors: 2 × AMD EPYC-Rome Processor
Memory: 1.9 GiB of RAM
Graphics Processor: virgl
Comment 4 Christoph Cullmann 2022-01-16 17:32:16 UTC
Git commit 3b31919427baf3da1ab1a24f682a4cefc7e5106f by Christoph Cullmann.
Committed on 16/01/2022 at 17:29.
Pushed by cullmann into branch 'master'.

Revert "Do not cancel mouse selection when using the keyboard"

This reverts commit 5dce70a9693f8cce37f733b4687bb9b303376742.

=> this leads to regressions

if somebody has time to properly reproduce and fix that, we can reapply
this, otherwise it is better to have some always working state without
this small usability improvement
Related: bug 447525

frameworks/ktexteditor#11

M  +10   -10   src/view/kateview.cpp
M  +0    -5    src/view/kateviewinternal.cpp
M  +0    -2    src/view/kateviewinternal.h

https://invent.kde.org/frameworks/ktexteditor/commit/3b31919427baf3da1ab1a24f682a4cefc7e5106f