Skip to content

Fix multiline code mining height alignment with text widget lines#4035

Merged
BeckerWdf merged 2 commits into
eclipse-platform:masterfrom
tobiasmelcher:styled_text_line_height
Jun 1, 2026
Merged

Fix multiline code mining height alignment with text widget lines#4035
BeckerWdf merged 2 commits into
eclipse-platform:masterfrom
tobiasmelcher:styled_text_line_height

Conversation

@tobiasmelcher
Copy link
Copy Markdown
Contributor

The line height of multiline code minings was computed via gc.stringExtent(line).y, which on Windows with Consolas at odd point sizes (e.g. 9, 11, 13) returns a different value than StyledText.getLineHeight(). As a result, the regular text lines drawn below a multiline code mining were shifted by a few pixels and no longer aligned with the rest of the text grid.

Use textWidget.getLineHeight() (plus textWidget.getLineSpacing()) in LineHeaderCodeMining.draw, AbstractCodeMining.draw and CodeMiningLineHeaderAnnotation.calculateLineHeight so each code mining line contributes exactly one StyledText line height.

@tobiasmelcher
Copy link
Copy Markdown
Contributor Author

Why this change?

While debugging multi-line code minings in LineHeaderCodeMining.draw(...), I noticed that the two height values used
for layout are not the same:

  • textWidget.getLineHeight() returns 18
  • gc.textExtent(line).y (the height returned per line by the GC) returns 17

See the screenshot from the debugger — lineHeight = 18 while ext.y = 17 for the same line of text:

line_height_ne_gc_y

The existing code stacks multiple lines of a header code mining by adding ext.y + textWidget.getLineHeight() per
iteration. Because ext.y (from gc.textExtent) can differ from the widget's actual line height, the lines drawn by the
code mining drift away from the line grid of the StyledText — visible as misaligned / overlapping rows once a mining
contains more than one line.

This PR switches the per-line advance to use textWidget.getLineHeight() consistently, so each line of a multi-line
code mining is placed exactly on the next line of the styled text widget, matching what the editor itself uses for
line spacing.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 29, 2026

Test Results

   864 files  ±0     864 suites  ±0   54m 38s ⏱️ +29s
 7 990 tests +2   7 747 ✅ +2  243 💤 ±0  0 ❌ ±0 
20 424 runs  +6  19 769 ✅ +6  655 💤 ±0  0 ❌ ±0 

Results for commit 90bbe10. ± Comparison against base commit 62c792e.

♻️ This comment has been updated with latest results.

@mickaelistria
Copy link
Copy Markdown
Contributor

tobiasmelcher requested a review from mickaelistria 3 days ago

Sorry, I don't plan to review this change shortly. But if it helps, you have all my trust ;)

The line height of multiline code minings was computed via
gc.stringExtent(line).y, which on Windows with Consolas at odd point
sizes (e.g. 9, 11, 13) returns a different value than
StyledText.getLineHeight(). As a result, the regular text lines drawn
below a multiline code mining were shifted by a few pixels and no
longer aligned with the rest of the text grid.

Use textWidget.getLineHeight() (plus textWidget.getLineSpacing()) in
LineHeaderCodeMining.draw, AbstractCodeMining.draw and
CodeMiningLineHeaderAnnotation.calculateLineHeight so each code mining
line contributes exactly one StyledText line height.
@BeckerWdf BeckerWdf force-pushed the styled_text_line_height branch from 9cdf97e to 23698e6 Compare June 1, 2026 07:21
@eclipse-platform-bot
Copy link
Copy Markdown
Contributor

This pull request changes some projects for the first time in this development cycle.
Therefore the following files need a version increment:

bundles/org.eclipse.jface.text/META-INF/MANIFEST.MF

An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch.

Git patch
From 6a50911507ca595ba08081e13b720c3abac62f13 Mon Sep 17 00:00:00 2001
From: Eclipse Platform Bot <platform-bot@eclipse.org>
Date: Mon, 1 Jun 2026 07:26:58 +0000
Subject: [PATCH] Version bump(s) for 4.41 stream


diff --git a/bundles/org.eclipse.jface.text/META-INF/MANIFEST.MF b/bundles/org.eclipse.jface.text/META-INF/MANIFEST.MF
index 653c7b05d9..decf753be7 100644
--- a/bundles/org.eclipse.jface.text/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.jface.text/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.jface.text
-Bundle-Version: 3.31.0.qualifier
+Bundle-Version: 3.31.100.qualifier
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
 Export-Package: 
-- 
2.54.0

Further information are available in Common Build Issues - Missing version increments.

@BeckerWdf BeckerWdf added this to the 4.41 M1 milestone Jun 1, 2026
@BeckerWdf BeckerWdf merged commit ff1f1b7 into eclipse-platform:master Jun 1, 2026
18 checks passed
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.

5 participants