Bug 391518

Summary: Cursor width in Kate gets narrower every 16 characters
Product: [Frameworks and Libraries] frameworks-ktexteditor Reporter: David de Cos <david.decos>
Component: generalAssignee: aryan10jangid
Status: RESOLVED FIXED    
Severity: normal CC: aryan10jangid, nate, oleh
Priority: NOR Keywords: junior-jobs
Version: unspecified   
Target Milestone: ---   
Platform: Neon   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Two screenshots put together, where both widths can be seen
attachment-19378-0.html

Description David de Cos 2018-03-07 12:28:21 UTC
Created attachment 111245 [details]
Two screenshots put together, where both widths can be seen

The width of the cursor in Kate depends on what column it is in. Most of the times its quite thick, but at some places of the document it's narrower.

The column numbers where it is narrow are: 1, 17, 33, 49, 65, 81, 97... (i.e. 16*n+1)

It's not a severe bug, but I find it slightly annoying, and the fact that those column numbers follow a mathematical pattern makes it interesting!
Comment 1 Christoph Feck 2018-03-29 22:45:57 UTC
The issue is that QTextLayout uses QPainter::RasterOp_NotDestination, which means all pixels that are affected by the cursor rect get inverted. Since the cursor rect is positioned at fractional positions, usually 3 instead of 2 pixels get inverted.

I suggest to use setRenderHint(QPainter::Antialiasing, false) for the cursor. This way, the rect rasterization will be pixel-aligned and only the intended 2 pixels get inverted.
Comment 2 aryan10jangid 2018-05-28 16:54:41 UTC
I'm able to reproduce this bug and I will try to fix the issue.
Comment 3 Oleh Prypin 2018-05-31 22:48:46 UTC
For me, the cursor appears thinner only at columns 1, 65, 129, ...
Another person reported the same (this was in IRC)

I'd like to note that I would prefer this to be fixed in the direction of making the cursor always thinner, rather than always thicker.
Comment 4 Christoph Feck 2018-06-04 19:43:05 UTC
Reassigning to affected repository to help juniors finding the code.
Comment 5 aryan10jangid 2018-06-05 13:55:51 UTC
Created attachment 113095 [details]
attachment-19378-0.html

Thank you C feck, I was trying to find the bug in Kate for 3 days:(

On Tue, Jun 5, 2018 at 1:13 AM, Christoph Feck <bugzilla_noreply@kde.org>
wrote:

> https://bugs.kde.org/show_bug.cgi?id=391518
>
> Christoph Feck <cfeck@kde.org> changed:
>
>            What    |Removed                     |Added
> ------------------------------------------------------------
> ----------------
>             Product|kate                        |frameworks-ktexteditor
>             Version|17.12.0                     |unspecified
>           Component|general                     |general
>
> --- Comment #4 from Christoph Feck <cfeck@kde.org> ---
> Reassigning to affected repository to help juniors finding the code.
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.
> You are the assignee for the bug.
>
Comment 6 Sven Brauch 2018-06-07 07:08:29 UTC
Git commit e6f87dd570082eb7f636b92f6ca88d85763ae687 by Sven Brauch, on behalf of Shubham Jangra.
Committed on 07/06/2018 at 07:07.
Pushed by brauch into branch 'master'.

Fix caret width

Differential Revision: https://phabricator.kde.org/D13365

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

https://commits.kde.org/ktexteditor/e6f87dd570082eb7f636b92f6ca88d85763ae687