Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2004-04-13 09:16:43 +0000
committerDani Megert2004-04-13 09:16:43 +0000
commit93b49c3a659e52fb0f6fac2fd1d7da0717d21ca9 (patch)
tree4f69d906e487df262ebb38d9960a7aa45484e3a6
parent18f3b53bff6e3f8f6bcaa7a48ab8b01fcd9abc19 (diff)
downloadeclipse.platform.text-93b49c3a659e52fb0f6fac2fd1d7da0717d21ca9.tar.gz
eclipse.platform.text-93b49c3a659e52fb0f6fac2fd1d7da0717d21ca9.tar.xz
eclipse.platform.text-93b49c3a659e52fb0f6fac2fd1d7da0717d21ca9.zip
Fixed bug 54922
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java61
1 files changed, 20 insertions, 41 deletions
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
index 031aa0de3..5699298a9 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
@@ -32,7 +32,6 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.custom.ST;
import org.eclipse.swt.custom.StyledText;
@@ -1653,10 +1652,10 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
*/
private Image fNonDefaultCaretImage;
/**
- * The styled text's default caret.
+ * The styled text's initial caret.
* @since 3.0
*/
- private Caret fDefaultCaret;
+ private Caret fInitialCaret;
/**
* Creates a new text editor. If not explicitly set, this editor uses
@@ -2597,8 +2596,8 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
extension.elementStateValidationChanged(input, false);
}
- if (fDefaultCaret == null)
- fDefaultCaret= getSourceViewer().getTextWidget().getCaret();
+ if (fInitialCaret == null)
+ fInitialCaret= getSourceViewer().getTextWidget().getCaret();
if (fIsOverwriting)
fSourceViewer.getTextWidget().invokeAction(ST.TOGGLE_OVERWRITE);
@@ -2786,25 +2785,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
}
disposeNonDefaultCaret();
-
- /* The following code exists to dispose a custom caret set e.g. by the
- * source viewer implementation. Note that StyledText does not set a
- * caret by default, so fDefaultCaret will usually be null.
- *
- * A source viewer that sets a custom caret on the widget does not
- * need to dispose it, or will run into an error_widget_disposed,
- * respectively.
- */
- if (fDefaultCaret != null && !fDefaultCaret.isDisposed()) {
- try {
- fDefaultCaret.dispose();
- // XXX: see SWT bug ???
- } catch (SWTException x) {
- if (x.code != SWT.ERROR_WIDGET_DISPOSED)
- throw x;
- }
- }
- fDefaultCaret= null;
+ fInitialCaret= null;
if (fForegroundColor != null) {
fForegroundColor.dispose();
@@ -4624,36 +4605,34 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
styledText.setCaret(null);
disposeNonDefaultCaret();
- if (getPreferenceStore().getBoolean(PREFERENCE_DISABLE_CUSTOM_CARETS))
- fNonDefaultCaret= createInsertCaret(styledText);
- else if (fIsOverwriting)
+ if (getPreferenceStore().getBoolean(PREFERENCE_DISABLE_CUSTOM_CARETS)) {
+ Assert.isTrue(fNonDefaultCaret == null);
+ } else if (fIsOverwriting)
fNonDefaultCaret= createOverwriteCaret(styledText);
else if (SMART_INSERT == mode)
fNonDefaultCaret= createInsertCaret(styledText);
else if (INSERT == mode)
fNonDefaultCaret= createRawInsertModeCaret(styledText);
- styledText.setCaret(fNonDefaultCaret);
- if (fNonDefaultCaret != null)
+ if (fNonDefaultCaret != null) {
+ styledText.setCaret(fNonDefaultCaret);
fNonDefaultCaretImage= fNonDefaultCaret.getImage();
+ } else if (fInitialCaret != styledText.getCaret())
+ styledText.setCaret(fInitialCaret);
}
private void disposeNonDefaultCaret() {
- if (fNonDefaultCaretImage != null && !fNonDefaultCaretImage.isDisposed())
+ if (fNonDefaultCaretImage != null) {
fNonDefaultCaretImage.dispose();
- fNonDefaultCaretImage= null;
+ fNonDefaultCaretImage= null;
+ }
- if (fNonDefaultCaret != null && !fNonDefaultCaret.isDisposed())
- try {
- fNonDefaultCaret.dispose();
- // XXX: see SWT bug ???
- } catch (SWTException x) {
- if (x.code != SWT.ERROR_WIDGET_DISPOSED)
- throw x;
- }
- fNonDefaultCaret= null;
+ if (fNonDefaultCaret != null) {
+ fNonDefaultCaret.dispose();
+ fNonDefaultCaret= null;
+ }
}
-
+
/**
* Handles a change of the editor's insert mode.
* Subclasses may extend.

Back to the top