https://bugs.kde.org/show_bug.cgi?id=524760

            Bug ID: 524760
           Summary: Caret drawn at wrong vertical position on wrapped
                    lines when Line Height Multiplier != 1.0 (regression
                    in 6.29.0)
    Classification: Frameworks and Libraries
           Product: frameworks-ktexteditor
      Version First 6.29.0
       Reported In:
          Platform: Manjaro
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

DESCRIPTION
Since upgrading ktexteditor 6.28.0 -> 6.29.0, the caret is painted too high on
dynamically wrapped lines. The error is zero on the first visual row of a
logical line and accumulates by a constant amount for every additional wrapped
row, so on long paragraphs the caret ends up roughly half a line above the text
it belongs to.

It only reproduces when "Line Height Multiplier" is set to something other than
1.0. Setting it back to 1.00 makes the problem disappear completely, which is
why the issue seems to depend on file type: files without long wrapped lines
(yaml/json/py in my case) never show it.

I searched bugs.kde.org for existing reports (products kate and
frameworks-ktexteditor, terms "line height", "caret", plus everything filed
since 2026-08-10) and found no duplicate.

STEPS TO REPRODUCE
1. Settings -> Editor -> Appearance: set Line Height Multiplier to 1.10.
2. Enable Dynamic Word Wrap.
3. Open a file containing one long paragraph that wraps over several visual
rows.
4. Place the caret on the 4th or later wrapped visual row.

OBSERVED RESULT
The caret is drawn above the row that actually contains the cursor. The
"highlight current line" band and the caret are on different rows. The offset
grows linearly with the index of the wrapped visual row.

EXPECTED RESULT
The caret is drawn on the same row as the text and the current-line highlight,
regardless of the Line Height Multiplier value.

MEASUREMENTS
Font Hack 12.5, Line Height Multiplier 1.1. Raw font line height = 24 px,
Kate's lineHeight() = 24 * 1.1 = 26.4 px. Measured from screenshots, with the
top of the text area at y=183:

  visual row 3: caret top = 183 + 3*24   = 255 px
                row  top = 183 + 3*26.4 = 262 px   (7 px off)
  visual row 5: caret top = 183 + 5*24   = 303 px
                row  top = 183 + 5*26.4 = 315 px   (12 px off)

So the caret advances by the un-multiplied font line height (24 px) while the
text rows advance by lineHeight() (26.4 px). The caret's *height* is correct
(26 px), only its y position is wrong.

LIKELY CAUSE
Commit 8b7ac04d "renderer: Fix drawing of all the cursor styles" changed
drawCursor() in src/render/katerenderer.cpp:

  - const qreal y = l.lineNumber() * height;
  + const qreal y = position.y() + (l.lineNumber() * l.height());

`height` is the caret height passed in by paintCaret(), derived from
KateRenderer::lineHeight(), which includes the Line Height Multiplier.
`l.height()` is QTextLine::height() from the Qt text layout, which does not.
With a multiplier of 1.0 the two are equal and nothing is visible; with any
other value the per-wrapped-row step is wrong by
lineHeight() - QTextLine::height(), which matches the measured 2.4 px/row.

I have not bisected or built from source, so please treat the attribution as a
strong hypothesis rather than a verified bisect.

SOFTWARE/OS VERSIONS
Operating System: Manjaro Linux
KDE Frameworks: ktexteditor 6.29.0-1
Kate: 26.04.3-1
Qt Version: 6.11.1
KDE Plasma Version: 6.7.4
Kernel: 6.12.104-1-MANJARO
Graphics Platform: Wayland
Global scale factor: 1.1875 (fractional; the 1.1 ratio above is independent of
it)

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to