Author: sdzmitrovich
Date: 2009-01-23 08:23:27 -0500 (Fri, 23 Jan 2009)
New Revision: 13237
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertContributionItem.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3620
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertContributionItem.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertContributionItem.java 2009-01-23
13:16:11 UTC (rev 13236)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertContributionItem.java 2009-01-23
13:23:27 UTC (rev 13237)
@@ -144,24 +144,26 @@
Point selectionRange = SelectionUtil
.getSourceSelectionRange(sourceEditor);
+ int start = selectionRange.x;
+ int length = selectionRange.y;
+
Node firstElement = SelectionUtil.getNodeBySourcePosition(sourceEditor,
selectionRange.x);
Node endElement = SelectionUtil.getNodeBySourcePosition(sourceEditor,
selectionRange.x + selectionRange.y);
- int start;
- int length;
+ if (firstElement != null)
+ if (firstElement.getNodeType() == Node.TEXT_NODE)
+ start = selectionRange.x;
+ else
+ start = NodesManagingUtil.getStartOffsetNode(firstElement);
- if (firstElement.getNodeType() == Node.TEXT_NODE)
- start = selectionRange.x;
- else
- start = NodesManagingUtil.getStartOffsetNode(firstElement);
+ if (endElement != null)
+ if (endElement.getNodeType() == Node.TEXT_NODE)
+ length = selectionRange.x + selectionRange.y - start;
+ else
+ length = NodesManagingUtil.getEndOffsetNode(endElement) - start;
- if (endElement.getNodeType() == Node.TEXT_NODE)
- length = selectionRange.x + selectionRange.y - start;
- else
- length = NodesManagingUtil.getEndOffsetNode(endElement) - start;
-
return new Point(start, length);
}