public void run() {
Region currentRegion = new Region(fViewer.getSelectedRange().x, fViewer.getSelectedRange().y);
if (currentRegion.getLength() == fViewer.getDocument().getLength())
return;
IndexedRegion cursorIndexedRegion = getCursorIndexedRegion();
if (cursorIndexedRegion instanceof Node) {
Node cursorNode = (Node) cursorIndexedRegion;
// use parent node for empty text node
if (cursorNode.getNodeType() == Node.TEXT_NODE && cursorNode.getNodeValue().trim().length() == 0) {
cursorNode = cursorNode.getParentNode();
if (cursorNode instanceof IndexedRegion)
cursorIndexedRegion = (IndexedRegion) cursorNode;
}
Region cursorNodeRegion = new Region(cursorIndexedRegion.getStartOffset(), cursorIndexedRegion.getEndOffset() - cursorIndexedRegion.getStartOffset());
Region newRegion = null;
if (cursorNodeRegion.getOffset() >= currentRegion.getOffset() && cursorNodeRegion.getOffset() <= currentRegion.getOffset() + currentRegion.getLength() && cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() >= currentRegion.getOffset() && cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() <= currentRegion.getOffset() + currentRegion.getLength())
newRegion = getNewSelectionRegion(cursorNode, currentRegion);
else