You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by jo...@apache.org on 2009/07/31 11:17:25 UTC
svn commit: r799552 -
/incubator/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java
Author: joern
Date: Fri Jul 31 09:17:24 2009
New Revision: 799552
URL: http://svn.apache.org/viewvc?rev=799552&view=rev
Log:
UIMA-1470
Modified:
incubator/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java
Modified: incubator/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java?rev=799552&r1=799551&r2=799552&view=diff
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java Fri Jul 31 09:17:24 2009
@@ -63,7 +63,6 @@
import org.eclipse.jface.text.source.AnnotationPainter;
import org.eclipse.jface.text.source.IAnnotationAccess;
import org.eclipse.jface.text.source.IAnnotationAccessExtension;
-import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.IAnnotationModelExtension;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewer;
@@ -945,9 +944,29 @@
- annotations.getFirst().getBegin());
// move caret to new position when selected outside of the editor
- if (AnnotationEditor.this != part)
- {
- getSourceViewer().getTextWidget().setCaretOffset(annotations.getLast().getEnd());
+ if (AnnotationEditor.this != part) {
+
+ // Note: The caret cannot be placed between line delimiters
+ // See bug UIMA-1470
+ int newCaretOffset = annotations.getLast().getEnd();
+ String text = getSourceViewer().getTextWidget().getText();
+
+ if (newCaretOffset > 0 && newCaretOffset < text.length()) {
+ char beforeCaret = text.charAt(newCaretOffset -1);
+ char afterCaret = text.charAt(newCaretOffset);
+
+ final int cr = 0x0D;
+ final int lf = 0x0A;
+ if (beforeCaret == cr && afterCaret == lf) {
+ // In case the caret offset is in the middle
+ // of a multiple-char line delimiter place caret
+ // before
+ newCaretOffset = newCaretOffset -1;
+ }
+ }
+
+ // check bounds, if out of text do nothing
+ getSourceViewer().getTextWidget().setCaretOffset(newCaretOffset);
}
}
}