Bug 475378 - Selected text background does not scroll with text
Summary: Selected text background does not scroll with text
Status: RESOLVED FIXED
Alias: None
Product: frameworks-ktexteditor
Classification: Frameworks and Libraries
Component: general (other bugs)
Version First Reported In: 5.245.0
Platform: Neon Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-08 18:23 UTC by myristica
Modified: 2024-02-13 11:04 UTC (History)
6 users (show)

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


Attachments
A video demonstrating the background text not aligned (305.52 KB, video/webm)
2023-10-08 18:23 UTC, myristica
Details
Screen recording demonstrating the odd behavior (1.35 MB, video/mp4)
2024-01-14 21:22 UTC, Rodrigo Pedra Brum
Details
Another screencast showing the problem (726.21 KB, video/mp4)
2024-02-09 15:35 UTC, Oded Arbel
Details
screencast of kate odd text selection behavior on increased line height (3.13 MB, video/mp4)
2024-02-09 23:51 UTC, Rodrigo Pedra Brum
Details

Note You need to log in before you can comment on or make changes to this bug.
Description myristica 2023-10-08 18:23:33 UTC
Created attachment 162168 [details]
A video demonstrating the background text not aligned

# SUMMARY
When not completely scrolled to the left, the selected text's background colour will not be aligned to the selected text, making it difficult to tell what is selected and renders the text unreadable.

STEPS TO REPRODUCE
1. Have long text that enables the horizontal scrollbar
2. Select part of it
3. Scroll to the right

OBSERVED RESULT
The selection background follows the view

EXPECTED RESULT
The selection background should stick with the selected text

SOFTWARE/OS VERSIONS
Kate: 23.08.1
Linux/KDE Plasma: KDE Neon 5.27
KDE Plasma Version: 5.27.8
KDE Frameworks Version: 5.110.0
Qt Version: 5.15.0
Graphics platform: Wayland

ADDITIONAL INFORMATION
I have tried reinstalling, disabling all addons. This issue does not affect kwrite nor kdevelop.
I also tested this on a clean plasma:unstable via `neondocker` with kate 23.11.70, where the issues still exists, though in another form that I believe is outside the scope of this report.
Note: I am guessing at the Component type
Comment 1 Christoph Cullmann 2023-10-09 16:28:35 UTC
Hmmm, that is very strange, as kwrite nor kdevelop use the same framework to render this.
Comment 2 Rodrigo Pedra Brum 2024-01-14 21:22:34 UTC
Created attachment 164906 [details]
Screen recording demonstrating the odd behavior

I have this odd behavior in Kate for a long time, but I haven't had the opportunity to search for an existing bug, or to properly report it.

When working with a file with long lines, text selection is very odd, and doesn't work as expected.

I added subtitles commenting out the behavior to the video, I will paste it here, for easier discoverability:

```
- Selection "scrolls" with horizontal scroll
- If cutting what seems to be selected, the original selection is actually cut
- (note, the expectation is the selection not be scrolled)
- Selecting when horizontal scroll is full at scroll start, works as expected
- Double-clicking a word, when horizontal scroll is full at scroll start, also works as expected
- But when moving the horizontal scroll, neither selecting text with a keyboard, or with a mouse, work as expected, as well cutting a text is odd
- When scrolling past the window width, even a displaced selection does not appear anymore
- (actually we can notice on all cases the "expected" selection gets is font color faded)
```

Apart from using the solarized light built-in theme, I don't have any other relevant customizations, or plugins added to Kate.

My installation info:

```
Operating System: openSUSE Tumbleweed 20240112
KDE Plasma Version: 5.27.10
KDE Frameworks Version: 5.114.0
Qt Version: 5.15.12
Kernel Version: 6.6.11-1-default (64-bit)
Graphics Platform: X11
```
Comment 3 Christoph Cullmann 2024-01-27 21:48:23 UTC
Hmm, yes, that looks broken, but I can not reproduce it.
Comment 4 Oded Arbel 2024-02-09 15:35:05 UTC
Created attachment 165701 [details]
Another screencast showing the problem

I think this is the same problem - though for me I'm more troubled about the blank boxes that appear and hide the text.

My repro is on Plasma 6 from testing, with Kate 24.01.95, and I didn't see this issue before Plasma 6

Operating System: KDE neon Testing Edition
KDE Plasma Version: 6.0.0
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.1
Kernel Version: 6.5.0-17-generic (64-bit)
Graphics Platform: Wayland
Processors: 20 × 12th Gen Intel® Core™ i7-12700H
Memory: 31.0 GiB of RAM
Graphics Processor: Mesa Intel® Graphics
Comment 5 Rodrigo Pedra Brum 2024-02-09 23:51:05 UTC
Created attachment 165711 [details]
screencast of kate odd text selection behavior on increased line height

So, I booted a live neon session on a VM, and to my surprise, stock Kate worked as expected.

So I decided to change settings, one by one, to match my local settings and find if some setting was the culprit.

Lucky me, I found it on the first settings screen: line height.

If one increases the line height setting, then the bug occurs. I made another screencast from a new VM using a neon live session.

For instance, in the video, I just increased it by one tick to 1.1. Locally, I use 1.2. But just by changing it, the odd behavior starts happening.

Please let me know if I can provide any further info.
Comment 6 Rodrigo Pedra Brum 2024-02-10 22:15:28 UTC
For completeness, setting the line-height back to 1 gets rid of the odd behavior, and text selection behaves as expected.
Comment 7 Oded Arbel 2024-02-11 14:23:55 UTC
(In reply to Rodrigo Pedra Brum from comment #6)
> For completeness, setting the line-height back to 1 gets rid of the odd
> behavior, and text selection behaves as expected.

In my case (Plasma 6), the line height is set to the default value of 1.0 (I don't remember ever changing it). Setting it to a different value causes a slightly different artifact, but not any less problematic.

The screencast in comment #4 is with the default line height of 1.0.

I can also reproduce the issue with kwrite. Both applications use kf6-ktexteditor from neon testing, version 5.245.0+p22.04+vstable+git20240210.0210-0
Comment 8 Rodrigo Pedra Brum 2024-02-12 06:55:30 UTC
Can you check if some other setting triggers the behavior? It would help the developers to track the root cause.

In my case, I planned to have the neon live instance and keep comparing settings one by one until I could reproduce.

To my luck, what triggered the bug on my install, was on the first settings page.
Comment 9 Bug Janitor Service 2024-02-12 07:16:27 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/667
Comment 10 Oded Arbel 2024-02-12 13:25:03 UTC
(In reply to Rodrigo Pedra Brum from comment #8)
> Can you check if some other setting triggers the behavior? 

I can reproduce the issue with the default Plasma 6 Kate configuration - after deleting all the configuration files I still reliably reproduce the problem. There is no custom setting that triggers it.
Comment 11 Waqar Ahmed 2024-02-13 11:04:06 UTC
Git commit 6cef6d842c27c635f856904aba3be4b7833e4b00 by Waqar Ahmed.
Committed on 12/02/2024 at 07:14.
Pushed by cullmann into branch 'master'.

Fix selection rendering with custom line height

M  +12   -5    src/render/katerenderer.cpp
M  +1    -1    src/render/katerenderer.h

https://invent.kde.org/frameworks/ktexteditor/-/commit/6cef6d842c27c635f856904aba3be4b7833e4b00
Comment 12 Waqar Ahmed 2024-02-13 11:04:14 UTC
Git commit f3ebff5fbcac9205d580b040f326543ac4baa784 by Waqar Ahmed.
Committed on 12/02/2024 at 07:15.
Pushed by cullmann into branch 'master'.

Dont apply clipping with selections

It breaks rendering with selections when dynamic wrapping is disabled

M  +2    -1    src/render/katerenderer.cpp

https://invent.kde.org/frameworks/ktexteditor/-/commit/f3ebff5fbcac9205d580b040f326543ac4baa784