From aae8e1648bbf3c412edf8e7231c54d41413896ad Mon Sep 17 00:00:00 2001 From: Deepika Udayagiri Date: Thu, 4 Jul 2024 14:54:16 +0530 Subject: [PATCH] Updated review comments. --- .../org/eclipse/swt/graphics/TextLayout.java | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java index 4e633a9c99..18cb93cadb 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java @@ -2952,18 +2952,11 @@ StyleItem[] merge (long items, int itemCount) { linkBefore = false; } char ch = segmentsText.charAt(start); - if(ch == '\r') { + if(ch == '\r' && (start+1 < end)) { ch = segmentsText.charAt(start+1); } - switch (ch) { - //case '\r': - case '\n': - item.lineBreak = true; - break; - case '\t': - item.tab = true; - break; - } + item.lineBreak = ch == '\n'; + item.tab = ch == '\t'; if (itemLimit == -1) { nextItemIndex = itemIndex + 1; OS.MoveMemory(scriptItem, items + nextItemIndex * SCRIPT_ITEM.sizeof, SCRIPT_ITEM.sizeof); @@ -3451,6 +3444,9 @@ public void setVerticalIndent (int verticalIndent) { */ public void setStyle (TextStyle style, int start, int end) { checkLayout(); + int length = text.length(); + if (length == 0) return; + if (start > end) return; int countNextLine = 0, noStyleCountNextLine = 0, loop = 0; if (previousEnd < 0) loop = previousEnd+1; @@ -3473,9 +3469,6 @@ public void setStyle (TextStyle style, int start, int end) { } previousEnd = end; end = end - previousCountNextLine; - int length = text.length(); - if (length == 0) return; - if (start > end) return; start = Math.min(Math.max(0, start), length - 1); end = Math.min(Math.max(0, end), length - 1); int low = -1;