-
Notifications
You must be signed in to change notification settings - Fork 183
Description
Originally posted by @raghucssit in #2489 (comment)
@raghucssit should we enhance javadoc to mention that calling copy / paste will not immediate update the state and one should possibly use asyncExec wif accessing the control is desired (that would probably also work for the test to use async exec but it of course complicates the test assertions maybe).
I have updated copy/paste doc.
I think this is incorrect to change this API from sync to async. This is probably a breaking change in SWT, but I pose this as a question because perhaps it is an acceptable change, but it is one that may have to extend to many more places (see below).
For example #2491 (comment) still failing is a side effect of this change because the asynchronous method* gtk_text_buffer_paste_clipboard is called just before calling applySegments, but applySegments needs the new value of the text buffer to operate properly.
Another example is this test that does effectively what TextCellEditor.performPaste
does, this test passes on GTK3, but fails with current GTK4 implementation.
@Test
public void test_paste_and_selection() {
text.setText("01234567890");
text.setSelection(2, 4);
assertEquals("01234567890", text.getText());
text.copy();
text.setSelection(3, 4);
assertEquals(1, text.getSelectionCount());
assertEquals(new Point(3, 4), text.getSelection());
// Simulate what code such as org.eclipse.jface.viewers.TextCellEditor.performPaste() does:
text.paste();
assertEquals(0, text.getSelectionCount());
assertEquals(new Point(5, 5), text.getSelection());
assertEquals("012234567890", text.getText());
}
* GTK4 changed this (and similar) methods from sync to async.