Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonah Graham2015-04-28 13:01:18 +0000
committerJonah Graham2015-04-28 13:01:18 +0000
commit34503e133eddc09872aaef315a6c9ab03e44f323 (patch)
tree38b62515be3688cf10cd88729563f8f3276a495e
parentb936046a1d0037087c1e87b96597b22cbb16e244 (diff)
downloadeclipse.platform.text-34503e133eddc09872aaef315a6c9ab03e44f323.tar.gz
eclipse.platform.text-34503e133eddc09872aaef315a6c9ab03e44f323.tar.xz
eclipse.platform.text-34503e133eddc09872aaef315a6c9ab03e44f323.zip
Change-Id: I8f79dbf19a4ee9994f545865c499974f0644bd5a Signed-off-by: Jonah Graham <jonah@kichwacoders.com>
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java9
-rw-r--r--org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/SegmentedModeTest.java38
2 files changed, 44 insertions, 3 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
index de4b96018..2028462b0 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,6 +10,7 @@
* Tom Eicher (Avaloq Evolution AG) - block selection mode
* Markus Schorn <markus.schorn@windriver.com> - shift with trailing empty line - https://bugs.eclipse.org/325438
* Sergey Prigogin (Google) - Bug 441827 - TextViewer.ViewerState.restore method looses caret position
+ * Jonah Graham (Kichwa Coders) - Bug 465684 - Fix initial setVisibleRegion of 0, 0
*******************************************************************************/
package org.eclipse.jface.text;
@@ -3007,8 +3008,12 @@ public class TextViewer extends Viewer implements
int offset= document.getLineOffset(line);
int length= (visibleRegionOffset - offset) + visibleRegionLength;
+ // Bug 465684: It is not possible to determine the difference between a
+ // set parent document range of 0, 0 vs an unset one. So in the 0, 0 case
+ // always set the parent document range.
Position parentRange= childDocument.getParentDocumentRange();
- if (offset != parentRange.getOffset() || length != parentRange.getLength()) {
+ if (offset != parentRange.getOffset() || length != parentRange.getLength()
+ || (offset == 0 && length == 0)) {
childDocument.setParentDocumentRange(offset, length);
return true;
}
diff --git a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/SegmentedModeTest.java b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/SegmentedModeTest.java
index ec4094d55..b3481fed0 100644
--- a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/SegmentedModeTest.java
+++ b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/SegmentedModeTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Jonah Graham (Kichwa Coders) - Bug 465684 - Fix initial setVisibleRegion of 0, 0
*******************************************************************************/
package org.eclipse.ui.editors.tests;
@@ -16,6 +17,7 @@ import junit.framework.TestSuite;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@@ -99,4 +101,38 @@ public class SegmentedModeTest extends TestCase {
assertTrue(false);
}
}
+
+ /*
+ * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=465684
+ */
+ public void testShowNothing() {
+ IWorkbench workbench= PlatformUI.getWorkbench();
+ IWorkbenchPage page= workbench.getActiveWorkbenchWindow().getActivePage();
+ try {
+ while (Display.getDefault().readAndDispatch()) {
+ }
+ IEditorPart part= IDE.openEditor(page, fFile);
+
+ try {
+ if (part instanceof ITextEditor) {
+ ITextEditor editor= (ITextEditor)part;
+
+ editor.showHighlightRangeOnly(true);
+ editor.setHighlightRange(0, 0, true);
+
+ Control control= (Control)part.getAdapter(Control.class);
+ if (control instanceof StyledText) {
+ StyledText styledText= (StyledText)control;
+ String text= styledText.getText();
+ assertEquals("", text);
+ }
+ }
+ } finally {
+ page.saveEditor(part, false);
+ }
+
+ } catch (PartInitException e) {
+ assertTrue(false);
+ }
+ }
}

Back to the top