Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Furnadjiev2014-01-30 16:07:13 +0000
committerIvan Furnadjiev2014-02-03 13:45:17 +0000
commit56a447454cc083af42d0d56611e24df8a3a7761a (patch)
tree83f0e855a8855f0227524f516b68392f3214304e
parenta42cd142074c173deeb0db2587decb7d87a65757 (diff)
downloadorg.eclipse.rap-56a447454cc083af42d0d56611e24df8a3a7761a.tar.gz
org.eclipse.rap-56a447454cc083af42d0d56611e24df8a3a7761a.tar.xz
org.eclipse.rap-56a447454cc083af42d0d56611e24df8a3a7761a.zip
Preserve the actual text selection value
When a verify listener is attached to the Text the selection value is preserved manually - see TextLCAUtil#readTextAndSelection. When client sends invalid selection (selectionStart is bigger than text length) the server adjusted the value in Text#setSelection(). To avoid rendering of this adjusted value back, the LCA should preserve the actual value and not the one sent by the client. 424118: [Text] Cursor reset to first character when typing fast https://bugs.eclipse.org/bugs/show_bug.cgi?id=424118 Change-Id: If8c72e196b3b64b6ad1038f900e1651c90c04d4d
-rw-r--r--bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/textkit/TextLCAUtil.java2
-rw-r--r--tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/internal/widgets/textkit/TextLCA_Test.java20
2 files changed, 19 insertions, 3 deletions
diff --git a/bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/textkit/TextLCAUtil.java b/bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/textkit/TextLCAUtil.java
index 5306b545e4..b996624543 100644
--- a/bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/textkit/TextLCAUtil.java
+++ b/bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/textkit/TextLCAUtil.java
@@ -132,7 +132,7 @@ final class TextLCAUtil {
adapter.preserve( PROP_TEXT, txt );
if( selection != null ) {
text.setSelection( selection );
- adapter.preserve( PROP_SELECTION, selection );
+ adapter.preserve( PROP_SELECTION, text.getSelection() );
}
}
} );
diff --git a/tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/internal/widgets/textkit/TextLCA_Test.java b/tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/internal/widgets/textkit/TextLCA_Test.java
index 3da12f4711..8348920d7d 100644
--- a/tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/internal/widgets/textkit/TextLCA_Test.java
+++ b/tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/internal/widgets/textkit/TextLCA_Test.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2013 Innoopract Informationssysteme GmbH and others.
+ * Copyright (c) 2002, 2014 Innoopract Informationssysteme GmbH 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
@@ -27,6 +27,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
+
import org.eclipse.rap.json.JsonArray;
import org.eclipse.rap.json.JsonObject;
import org.eclipse.rap.json.JsonValue;
@@ -130,7 +131,7 @@ public class TextLCA_Test {
assertEquals( new Point( 1, 2 ), text.getSelection() );
}
-
+
@Test
public void testModifyEvent() {
ModifyListener listener = mock( ModifyListener.class );
@@ -222,6 +223,21 @@ public class TextLCA_Test {
}
@Test
+ public void testSelectionWithVerifyListener_adjustedValueIsNotRenderedBack() {
+ Fixture.markInitialized( display );
+ Fixture.markInitialized( text );
+ text.addVerifyListener( mock( VerifyListener.class ) );
+ Fixture.fakeSetProperty( getId( text ), "text", "abc" );
+ Fixture.fakeSetProperty( getId( text ), "selectionStart", 10 );
+ Fixture.fakeSetProperty( getId( text ), "selectionLength", 0 );
+
+ Fixture.executeLifeCycleFromServerThread();
+
+ Message message = Fixture.getProtocolMessage();
+ assertNull( message.findSetOperation( text, "selection" ) );
+ }
+
+ @Test
public void testPreserveText() {
Fixture.markInitialized( display );
Fixture.markInitialized( text );

Back to the top