Skip to content

fix(editor): paint the image gap right under its line - #203

Closed
gnacho wants to merge 1 commit into
masterfrom
fix/202-empty-alt-gap
Closed

gnacho wants to merge 1 commit into
masterfrom
fix/202-empty-alt-gap

Conversation

@gnacho

@gnacho gnacho commented Nov 18, 2026

Copy link
Copy Markdown
Owner

An image with an empty alt was painted one gap below its line, so the paragraph after it ended up beside the image. ![](images/foto.png) was the broken case, ![foto](images/foto.png) with any alt was fine.

Cause: gap_top() guessed whether the reported line height already contains the imagegap space with line_h > gap + 8.0. With an empty alt the line holds only shrunk marks, so its height is exactly the gap and the comparison failed. The code then added the line height a second time.

Fix: the decision is now line_h >= gap, extracted into the pure gap_top_for() with unit tests for the four cases (empty line, line with text, height that does not cover the gap yet, and a tiny requested gap).

Verified with the release build in Xvfb: empty alt, empty alt with |240, alt with text and a 48 px image. In all four the paragraph after the image sits below it. Before the fix the empty alt cases had the image one gap lower and the paragraph beside it.

Closes #202

@gnacho gnacho closed this Nov 19, 2026
@gnacho
gnacho deleted the fix/202-empty-alt-gap branch November 19, 2026 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An image with an empty alt is drawn one gap below its line

1 participant