Bug 499669

Summary: Cursor of multi-line edit is not aligned when there is line-ending
Product: [Applications] kate Reporter: Firestar-Reimu <1900011604>
Component: kwriteAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: christoph, justin, waqar.17a
Priority: NOR    
Version First Reported In: 24.12.2   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Picture 1
Picture 2

Description Firestar-Reimu 2025-02-08 02:22:20 UTC
Cursor of multi-line edit is not aligned when there are spaces

See Picture 1, the second line is not aligned because there is a line-ending

See Picture 2, this area should be a simple rectangle, but it is ragged
Comment 1 Firestar-Reimu 2025-02-08 02:23:47 UTC
Created attachment 178059 [details]
Picture 1
Comment 2 Firestar-Reimu 2025-02-08 02:24:35 UTC
Created attachment 178060 [details]
Picture 2
Comment 3 Justin Zobel 2025-02-10 09:47:25 UTC
Can you please fill out the steps to reproduce and the system info? It helps developers understand how to reproduce the issue and what underlying software e.g. Qt and KDE Frameworks are in use.

Please change the status back to REPORTED when you reply with the requested information. Thank you.

STEPS TO REPRODUCE
1. 
2. 
3. 

OBSERVED RESULT


EXPECTED RESULT


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma: 
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version:
Comment 4 Waqar Ahmed 2025-02-10 11:59:39 UTC
can see the issue, but dont think it has anything to do with "spaces" or line endings.
Comment 5 Waqar Ahmed 2025-02-11 06:59:53 UTC
seems like if the horizontalAdvance of a font has a fractional part, then the x calculation in KateRenderer::cursorToX is slightly off when the cursor is past the end of line.

Tested with "Intel One Mono, Size:11"
Comment 6 Christoph Cullmann 2025-02-16 21:21:00 UTC
Guess we could use like Qt there qreal in a more consistent way.
Comment 7 Bug Janitor Service 2025-02-16 21:27:22 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/787
Comment 8 Waqar Ahmed 2025-02-17 05:19:35 UTC
Git commit fbf5a1d47ed5cb539c19427833405e164423c1b8 by Waqar Ahmed, on behalf of Christoph Cullmann.
Committed on 17/02/2025 at 05:14.
Pushed by waqar into branch 'master'.

compute at least inside cursorToX with floats

M  +5    -8    src/render/katerenderer.cpp
M  +2    -2    src/render/katerenderer.h

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