Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundles/org.eclipse.ui.editors/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.ui.editors; singleton:=true
Bundle-Version: 3.21.0.qualifier
Bundle-Version: 3.21.100.qualifier
Bundle-Activator: org.eclipse.ui.internal.editors.text.EditorsPlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,10 @@ private void calculateAndSetStickyLinesCanvasBounds() {
StyledText textWidget= sourceViewer.getTextWidget();

int numberStickyLines= getNumberStickyLines();
int lineHeight= stickyLineText.getLineHeight() * numberStickyLines;
int lineHeight= 0;
for (int i= 0; i < numberStickyLines; i++) {
lineHeight+= stickyLineText.getLineHeight(stickyLineText.getOffsetAtLine(i));
}
int spacingHeight= stickyLineText.getLineSpacing() * (numberStickyLines - 1);
int separatorHeight= bottomSeparator.getBounds().height;

Expand Down Expand Up @@ -450,7 +453,8 @@ private boolean areStickyLinesOutDated(StyledText textWidget) {
}

private void limitVisibleStickyLinesToTextWidgetHeight(StyledText textWidget) {
int lineHeight= textWidget.getLineHeight() + textWidget.getLineSpacing();
int topOffset= textWidget.getOffsetAtLine(textWidget.getTopIndex());
int lineHeight= textWidget.getLineHeight(topOffset) + textWidget.getLineSpacing();
int textWidgetHeight= textWidget.getBounds().height;

int visibleLinesInTextWidget= textWidgetHeight / lineHeight;
Expand Down
2 changes: 1 addition & 1 deletion tests/org.eclipse.ui.editors.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Plugin.name
Bundle-SymbolicName: org.eclipse.ui.editors.tests;singleton:=true
Bundle-Version: 3.14.0.qualifier
Bundle-Version: 3.14.100.qualifier
Bundle-Vendor: %Plugin.providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.jface.text.tests.codemining,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import static org.hamcrest.Matchers.greaterThan;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -236,6 +237,31 @@ void testStyling() {
assertEquals(hoverColor, stickyLineText.getForeground());
}

@Test
void testCanvasBoundsHeightAdjustsForVariableLineHeights() {
sourceViewer.getTextWidget().setBounds(0, 0, 200, 200);

// Step 1: Set 2 plain-text sticky lines and record canvas height
List<IStickyLine> plainLines = List.of(
new StickyLineStub("line 1", 0),
new StickyLineStub("line 2", 1));
stickyScrollingControl.setStickyLines(plainLines);
Canvas stickyControlCanvas = getStickyControlCanvas(shell);
int heightWithPlainText = stickyControlCanvas.getBounds().height;

// Step 2: Replace second sticky line with emoji requiring more vertical space
List<IStickyLine> emojiLines = List.of(
new StickyLineStub("line 1", 0),
new StickyLineStub("\uD83D\uDE00\uD83D\uDE80\uD83C\uDF1F", 1));
stickyScrollingControl.setStickyLines(emojiLines);
stickyControlCanvas = getStickyControlCanvas(shell);
int heightWithEmoji = stickyControlCanvas.getBounds().height;

// Step 3: Assert emoji causes taller canvas (documents the actual bug)
assertTrue(heightWithEmoji > heightWithPlainText,
"Canvas height should increase when sticky lines contain emoji with larger line heights");
}

@Test
void testLayoutStickyLinesCanvasOnResize() {
sourceViewer.getTextWidget().setBounds(0, 0, 200, 200);
Expand Down
Loading