Skip to content

Commit aae8e16

Browse files
committed
Updated review comments.
1 parent 6736342 commit aae8e16

File tree

1 file changed

+6
-13
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics

1 file changed

+6
-13
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2952,18 +2952,11 @@ StyleItem[] merge (long items, int itemCount) {
29522952
linkBefore = false;
29532953
}
29542954
char ch = segmentsText.charAt(start);
2955-
if(ch == '\r') {
2955+
if(ch == '\r' && (start+1 < end)) {
29562956
ch = segmentsText.charAt(start+1);
29572957
}
2958-
switch (ch) {
2959-
//case '\r':
2960-
case '\n':
2961-
item.lineBreak = true;
2962-
break;
2963-
case '\t':
2964-
item.tab = true;
2965-
break;
2966-
}
2958+
item.lineBreak = ch == '\n';
2959+
item.tab = ch == '\t';
29672960
if (itemLimit == -1) {
29682961
nextItemIndex = itemIndex + 1;
29692962
OS.MoveMemory(scriptItem, items + nextItemIndex * SCRIPT_ITEM.sizeof, SCRIPT_ITEM.sizeof);
@@ -3451,6 +3444,9 @@ public void setVerticalIndent (int verticalIndent) {
34513444
*/
34523445
public void setStyle (TextStyle style, int start, int end) {
34533446
checkLayout();
3447+
int length = text.length();
3448+
if (length == 0) return;
3449+
if (start > end) return;
34543450
int countNextLine = 0, noStyleCountNextLine = 0, loop = 0;
34553451
if (previousEnd < 0)
34563452
loop = previousEnd+1;
@@ -3473,9 +3469,6 @@ public void setStyle (TextStyle style, int start, int end) {
34733469
}
34743470
previousEnd = end;
34753471
end = end - previousCountNextLine;
3476-
int length = text.length();
3477-
if (length == 0) return;
3478-
if (start > end) return;
34793472
start = Math.min(Math.max(0, start), length - 1);
34803473
end = Math.min(Math.max(0, end), length - 1);
34813474
int low = -1;

0 commit comments

Comments
 (0)