aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiraj Modi2013-11-21 05:36:21 (EST)
committerArun Thondapu2013-11-21 05:36:21 (EST)
commit46fe45c0a21748cabb5cb937f09a7e0bab32eee7 (patch)
tree7c62342c9b3c5e4b8cc1cf9b14d9158dbbaf1693
parente4fc1dcfe6803dfc1d7ea1f8ada41a2682e5fd00 (diff)
downloadeclipse.platform.swt-46fe45c0a21748cabb5cb937f09a7e0bab32eee7.zip
eclipse.platform.swt-46fe45c0a21748cabb5cb937f09a7e0bab32eee7.tar.gz
eclipse.platform.swt-46fe45c0a21748cabb5cb937f09a7e0bab32eee7.tar.bz2
Bug 421045 - NPE in StyledText.getVisualLineIndexv4412dI20131126-0800
Signed-off-by: Niraj Modi <niraj.modi@in.ibm.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
index 0bc8371..c05c373 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
@@ -5269,9 +5269,10 @@ int getVerticalScrollOffset() {
int getVisualLineIndex(TextLayout layout, int offsetInLine) {
int lineIndex = layout.getLineIndex(offsetInLine);
int[] offsets = layout.getLineOffsets();
- if (lineIndex != 0 && offsetInLine == offsets[lineIndex]) {
+ Caret caret = getCaret();
+ if (caret != null && lineIndex != 0 && offsetInLine == offsets[lineIndex]) {
int lineY = layout.getLineBounds(lineIndex).y;
- int caretY = getCaret().getLocation().y - getLinePixel(getCaretLine());
+ int caretY = caret.getLocation().y - getLinePixel(getCaretLine());
if (lineY > caretY) lineIndex--;
caretAlignment = OFFSET_LEADING;
}