From 97f0dbc31d9e7eed6ac3ae3300968a3d231270fe Mon Sep 17 00:00:00 2001 From: cashmere Date: Sun, 29 Mar 2026 08:39:08 +0200 Subject: fix: skip heading rendering when folded to same visual line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When org folds headings (S-TAB overview mode), the newline after each heading becomes invisible, causing multiple headings to appear on the same visual line. posn-at-point then reports col > 1 for headings that follow the fold ellipsis of a previous heading. Placing scaled text at col > 1 causes horizontal drift — headings rendered mid-line overlapping with fold ellipsis and each other. Fix: org headings always start at buffer column 0. If the computed terminal column is not 1, the heading is in a folded context where rendering at scale would be wrong. Skip it (treat as not visible), erase any previous placement, and let the refresh cycle re-place it when unfolded. Root cause identified via debug log analysis showing: Before fold: all headings at col=1 (correct) After S-TAB: headings at col=21/24 on same row (wrong) --- kitty-graphics.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/kitty-graphics.el b/kitty-graphics.el index 845c756..60a1e70 100644 --- a/kitty-graphics.el +++ b/kitty-graphics.el @@ -1271,8 +1271,15 @@ avoid posn-at-point redraws destroying freshly-placed blocks." (last-col (overlay-get ov 'kitty-gfx-last-col))) (if (and pos (<= (car pos) win-bottom) - (<= (+ (car pos) rows -1) win-bottom)) - ;; Visible — erase old position if moved, cache new position + (<= (+ (car pos) rows -1) win-bottom) + ;; Guard: org headings always start at column 1 (buffer + ;; line beginning). If posn-at-point reports col > 1, + ;; the heading is visually mid-line due to org fold + ;; collapsing newlines between headings (S-TAB overview + ;; mode). Skip rendering — placing a scaled heading + ;; mid-line overlaps with fold ellipsis and other headings. + (= (cdr pos) 1)) + ;; Visible at column 1 — erase old position if moved, cache new (let ((new-row (car pos)) (new-col (cdr pos))) (when (and last-row -- cgit v1.3.1