private static final IRegion getSignedSelection(ISourceViewer sourceViewer) {
		Point viewerSelection= sourceViewer.getSelectedRange();

		StyledText text= sourceViewer.getTextWidget();
		Point selection= text.getSelectionRange();
		if (text.getCaretOffset() == selection.x) {
			viewerSelection.x= viewerSelection.x + viewerSelection.y;
			viewerSelection.y= -viewerSelection.y;
		}

		return new Region(viewerSelection.x, viewerSelection.y);
	}
Returns the signed current selection. The length will be negative if the resulting selection
is right-to-left.
<p>
The selection offset is model based.
</p>

@param sourceViewer the source viewer
@return a region denoting the current signed selection, for a resulting RtoL selections
        length is < 0
@since 3.8
plugins/org.jkiss.dbeaver.ui.editors.sql/src/org/jkiss/dbeaver/ui/editors/sql/SQLMatchingCharacterPainter.java