Skip to content

Commit 3df8fde

Browse files
tobias-melcherBeckerWdf
authored andcommitted
StyledText#setLineVerticalIndent: fix overlapping code minings in editor
Ensure problem annotation code minings are rendered below source lines to prevent visual overlap during vertical scrolling. Fixes: #2512
1 parent 8c237c5 commit 3df8fde

File tree

1 file changed

+15
-6
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom

1 file changed

+15
-6
lines changed

bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4265,12 +4265,20 @@ public int getOrientation () {
42654265
*/
42664266
int getPartialBottomIndex() {
42674267
if (isFixedLineHeight()) {
4268-
int lineHeight = renderer.getLineHeight();
4269-
int partialLineCount = Compatibility.ceil(clientAreaHeight, lineHeight);
4270-
return Math.max(0, Math.min(content.getLineCount(), topIndex + partialLineCount) - 1);
4268+
return getPartialBottomIndexFixedLineHeight();
42714269
}
42724270
return getLineIndex(clientAreaHeight - bottomMargin);
42734271
}
4272+
/**
4273+
* Returns the index of the last partially visible line assuming a fixed line height.
4274+
*
4275+
* @return index of the last partially visible line.
4276+
*/
4277+
private int getPartialBottomIndexFixedLineHeight() {
4278+
int lineHeight = renderer.getLineHeight();
4279+
int partialLineCount = Compatibility.ceil(clientAreaHeight, lineHeight);
4280+
return Math.max(0, Math.min(content.getLineCount(), topIndex + partialLineCount) - 1);
4281+
}
42744282
/**
42754283
* Returns the index of the first partially visible line.
42764284
*
@@ -9315,7 +9323,8 @@ public void setLineVerticalIndent(int lineIndex, int verticalLineIndent) {
93159323
}
93169324
int initialTopPixel = getTopPixel();
93179325
int initialTopIndex = getPartialTopIndex();
9318-
int initialBottomIndex = getPartialBottomIndex();
9326+
// use getPartialBottomIndexFixedLineHeight to include more additional lines to fix scrolling issue eclipse-platform/eclipse.platform.swt#2512
9327+
int initialBottomIndex = getPartialBottomIndexFixedLineHeight();
93199328
int verticalIndentDiff = verticalLineIndent - previousVerticalIndent;
93209329
renderer.setLineVerticalIndent(lineIndex, verticalLineIndent);
93219330
this.hasVerticalIndent = verticalLineIndent != 0 || renderer.hasVerticalIndent();
@@ -9332,8 +9341,8 @@ public void setLineVerticalIndent(int lineIndex, int verticalLineIndent) {
93329341
}
93339342
} else {
93349343
resetCache(lineIndex, 1);
9335-
if((initialTopIndex == 0) && (initialBottomIndex == (content.getLineCount() - 1))) { // not scrollable editor
9336-
setCaretLocations();
9344+
if ((initialTopIndex == 0) && (initialBottomIndex == (content.getLineCount() - 1))) { // not scrollable editor
9345+
setCaretLocations();
93379346
redrawLines(lineIndex, getBottomIndex() - lineIndex + 1, true);
93389347
} else if (getFirstCaretLine() >= initialTopIndex && getFirstCaretLine() <= initialBottomIndex) { // caret line with caret mustn't move
93399348
if (getFirstCaretLine() < lineIndex) {

0 commit comments

Comments
 (0)