Skip to content
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

Find/Replace overlay: fix Ctrl+F6 crash on Linux #1975

Merged
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 @@ -247,21 +247,17 @@ public void shellDeactivated(ShellEvent e) {
private IPartListener partListener = new IPartListener() {
@Override
public void partActivated(IWorkbenchPart part) {
if (getShell() != null) {
getShell().setVisible(isPartCurrentlyDisplayedInPartSash());
}
getShell().getDisplay().asyncExec(this::adaptToPartActivationChange);
}

@Override
public void partDeactivated(IWorkbenchPart part) {
// Do nothing
getShell().getDisplay().asyncExec(this::adaptToPartActivationChange);
}

@Override
public void partBroughtToTop(IWorkbenchPart part) {
if (getShell() != null) {
getShell().setVisible(isPartCurrentlyDisplayedInPartSash());
}
getShell().getDisplay().asyncExec(this::adaptToPartActivationChange);
}

@Override
Expand All @@ -273,6 +269,35 @@ public void partClosed(IWorkbenchPart part) {
public void partOpened(IWorkbenchPart part) {
// Do nothing
}

private void adaptToPartActivationChange() {
if (getShell() == null || targetPart.getSite().getPart() == null) {
return;
}

boolean isOverlayVisible = isPartCurrentlyDisplayedInPartSash();

getShell().setVisible(isOverlayVisible);

if (isOverlayVisible) {
targetPart.getSite().getShell().setActive();
targetPart.setFocus();
getShell().getDisplay().asyncExec(this::focusTargetWidget);
}
}

private void focusTargetWidget() {
if (getShell() == null || targetPart.getSite().getPart() == null) {
return;
}
if (!(targetPart instanceof StatusTextEditor)) {
return;
}
StatusTextEditor textEditor = (StatusTextEditor) targetPart;
Control targetWidget = textEditor.getAdapter(ITextViewer.class).getTextWidget();

targetWidget.forceFocus();
}
};

private boolean isPartCurrentlyDisplayedInPartSash() {
Expand Down
Loading