Skip to content

Commit c9f5370

Browse files
r-mennigvogella
authored andcommitted
Fix error with search in XMI-tab of E4WorkbenchModelEditor
Consider updated text field after key press when searching in the xmi tab instead of the out-dated one
1 parent 50600c6 commit c9f5370

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

  • e4tools/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs

e4tools/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/tabs/XmiTab.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@
4141
import org.eclipse.jface.text.source.SourceViewer;
4242
import org.eclipse.jface.text.source.VerticalRuler;
4343
import org.eclipse.swt.SWT;
44-
import org.eclipse.swt.events.KeyAdapter;
45-
import org.eclipse.swt.events.KeyEvent;
44+
import org.eclipse.swt.events.KeyListener;
4645
import org.eclipse.swt.layout.GridData;
4746
import org.eclipse.swt.layout.GridLayout;
4847
import org.eclipse.swt.widgets.Composite;
@@ -88,14 +87,15 @@ protected void postConstruct() {
8887
text = new Text(this, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
8988
text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
9089
text.setMessage(Messages.XmiTab_TypeTextToSearch);
91-
text.addKeyListener(new KeyAdapter() {
92-
@Override
93-
public void keyPressed(KeyEvent e) {
94-
if (e.keyCode != SWT.CR) {
95-
offsetStart = 0;
96-
}
90+
text.addKeyListener(KeyListener.keyPressedAdapter(e -> {
91+
if (e.keyCode != SWT.CR) {
92+
offsetStart = 0;
93+
} else { // search next occurrence
9794
offsetStart = searchAndHighlight(text.getText(), offsetStart);
9895
}
96+
}));
97+
text.addModifyListener(e -> {
98+
offsetStart = searchAndHighlight(text.getText(), offsetStart);
9999
});
100100

101101
final AnnotationModel model = new AnnotationModel();

0 commit comments

Comments
 (0)