Skip to content

[Find/Replace dialog][Linux] "Replace" buttons remain disabled when using "Enter" #2882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,15 @@ public void shellDeactivated(ShellEvent e) {
*/
private class InputModifyListener implements ModifyListener {

private Runnable modificationHandler;
private final Runnable logicUpdateHandler;
private final Runnable uiUpdateHandler;

// XXX: Workaround for Combo bug on Linux (see bug 404202 and bug 410603)
private boolean fIgnoreNextEvent;

private InputModifyListener(Runnable modificationHandler) {
this.modificationHandler = modificationHandler;
private InputModifyListener(Runnable logicUpdateHandler, Runnable uiUpdateHandler) {
this.logicUpdateHandler = logicUpdateHandler;
this.uiUpdateHandler = uiUpdateHandler;
}

private void ignoreNextEvent() {
Expand All @@ -144,13 +146,15 @@ private void ignoreNextEvent() {

@Override
public void modifyText(ModifyEvent e) {
modificationHandler.run();
// Data in logic needs to updated immediately (i.e., find or replace string)
logicUpdateHandler.run();
// XXX: Workaround for Combo bug on Linux (see bug 404202 and bug 410603)
// UI must only be updated after second event on Linux
if (fIgnoreNextEvent) {
fIgnoreNextEvent = false;
return;
}
modificationHandler.run();
uiUpdateHandler.run();
}
}

Expand Down Expand Up @@ -644,8 +648,7 @@ private Composite createInputPanel(Composite parent) {
ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, new char[0], true);
setGridData(fFindField, SWT.FILL, true, SWT.CENTER, false);
addDecorationMargin(fFindField);
fFindModifyListener = new InputModifyListener(() -> {
updateFindString();
fFindModifyListener = new InputModifyListener(this::updateFindString, () -> {
updateButtonState(!findReplaceLogic.isActive(SearchOptions.INCREMENTAL));
decorate();
});
Expand All @@ -663,12 +666,7 @@ private Composite createInputPanel(Composite parent) {
ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, new char[0], true);
setGridData(fReplaceField, SWT.FILL, true, SWT.CENTER, false);
addDecorationMargin(fReplaceField);
fReplaceModifyListener = new InputModifyListener(() -> {
if (okToUse(fReplaceField)) {
findReplaceLogic.setReplaceString(fReplaceField.getText());
}
updateButtonState();
});
fReplaceModifyListener = new InputModifyListener(this::updateReplaceString, this::updateButtonState);
fReplaceField.addModifyListener(fReplaceModifyListener);

return panel;
Expand All @@ -680,6 +678,12 @@ private void updateFindString() {
}
}

private void updateReplaceString() {
if (okToUse(fReplaceField)) {
findReplaceLogic.setReplaceString(fReplaceField.getText());
}
}

/**
* Creates the functional options part of the options defining section of the
* find replace dialog.
Expand Down
Loading