Author: dmaliarevich
Date: 2011-11-03 04:40:23 -0400 (Thu, 03 Nov 2011)
New Revision: 36157
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java
Log:
https://issues.jboss.org/browse/JBIDE-9548 - if statement was corrected.
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java 2011-11-03
06:40:32 UTC (rev 36156)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java 2011-11-03
08:40:23 UTC (rev 36157)
@@ -348,11 +348,18 @@
* Without <span> for text nodes -- there is an
* string out of bounds exception.
*/
- int substringPosition = sourcePosition;
- if (sourceText.length() < sourcePosition) {
- substringPosition = sourceText.length() - 1;
+ int endPos = sourcePosition;
+ int length = sourceText.length();
+ String s1 = sourceText;
+ /*
+ * If sourceText is not empty -- correct endPos
+ */
+ if (length > 0) {
+ if (endPos > length) {
+ endPos = length;
+ }
+ s1 = sourceText.substring(0, endPos);
}
- String s1 = sourceText.substring(0, substringPosition);
String s2 = s1.replaceAll(SOURCE_BREAK, VISUAL_BREAK);
return calcPosition - (s1.length() - s2.length());
}