summaryrefslogtreecommitdiff
path: root/kde-frameworks/ktexteditor/files/ktexteditor-6.31.0-fix-caret-rendering-for-lineheight-scaling.patch
blob: 0b248a4b12b9be8c2b92a494e7361830b93645f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
From c8e141588adce66f26835a7c5d4c1046651abd6e Mon Sep 17 00:00:00 2001
From: Christoph Cullmann <christoph@cullmann.dev>
Date: Sun, 11 Oct 2026 19:15:29 +0200
Subject: [PATCH] rendering: fix caret rendering for line height scaling

pass lineHeight to ensure we work fine with wrapped lines
and lineHeightMultiplier != 1.0

BUG: 524760
---
 src/render/katerenderer.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/render/katerenderer.cpp b/src/render/katerenderer.cpp
index a8d5fde13..636b98db4 100644
--- a/src/render/katerenderer.cpp
+++ b/src/render/katerenderer.cpp
@@ -951,7 +951,7 @@ void KateRenderer::paintTextLine(QPainter &paint,
     }
 }
 
-static void drawCursor(const QTextLayout &layout, QPainter *p, const QPointF &pos, int cursorPosition, int width, const int height)
+static void drawCursor(const QTextLayout &layout, QPainter *p, const QPointF &pos, int cursorPosition, int width, const int height, const int lineHeight)
 {
     cursorPosition = qBound(0, cursorPosition, layout.text().length());
     const QTextLine l = layout.lineForTextPosition(cursorPosition);
@@ -966,7 +966,7 @@ static void drawCursor(const QTextLayout &layout, QPainter *p, const QPointF &po
 
     const QPointF position = pos + layout.position();
     const qreal x = position.x() + l.cursorToX(cursorPosition);
-    const qreal y = position.y() + (l.lineNumber() * l.height());
+    const qreal y = position.y() + (l.lineNumber() * lineHeight);
     p->fillRect(QRectF(x, y, (qreal)width, (qreal)height), p->pen().brush());
     p->setCompositionMode(origCompositionMode);
 }
@@ -1045,7 +1045,9 @@ void KateRenderer::paintCaret(KTextEditor::Cursor cursor, KateLineLayout *range,
                 }
             }
         }
-        drawCursor(range->layout(), &paint, QPoint(-xStart - width, lineHeight() - caretHeight), cursor.column(), caretWidth, caretHeight);
+
+        // pass lineHeight to ensure we work fine with wrapped lines and lineHeightMultiplier != 1.0, bug 524760
+        drawCursor(range->layout(), &paint, QPoint(-xStart - width, lineHeight() - caretHeight), cursor.column(), caretWidth, caretHeight, lineHeight());
     } else {
         // Off the end of the line... must be block mode. Draw the caret ourselves.
         const KateTextLayout &lastLine = range->viewLine(range->viewLineCount() - 1);
-- 
GitLab