Skip to content

Commit

Permalink
Find/Replace overlay: handle the case when moving editor between windows
Browse files Browse the repository at this point in the history
When moving the targeted editor between different windows, the overlay
is closed to allow a retargetting.

fixes #1945
  • Loading branch information
Wittmaxi authored and HeikoKlare committed Jul 16, 2024
1 parent a5689de commit d121c1e
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,15 @@ private void updatePlacementAndVisibility() {
getShell().setVisible(false);
return;
}
if (isInvalidTargetShell()) {
getShell().getDisplay().syncExec(() -> {
close();
setParentShell(targetPart.getSite().getShell());
open();
targetPart.setFocus();
});
return;
}
getShell().requestLayout();
if (!(targetPart instanceof StatusTextEditor textEditor)) {
return;
Expand All @@ -902,6 +911,17 @@ private void updatePlacementAndVisibility() {
repositionTextSelection();
}

private boolean isInvalidTargetPart() {
return targetPart == null || targetPart.getSite() == null || targetPart.getSite().getShell() == null;
}

private boolean isInvalidTargetShell() {
if (isInvalidTargetPart()) {
return false;
}
return getShell() == null || !targetPart.getSite().getShell().equals(getShell().getParent());
}

private Rectangle calculateAbsoluteControlBounds(Control control) {
Rectangle localControlBounds = control.getBounds();
int width = localControlBounds.width;
Expand Down

0 comments on commit d121c1e

Please sign in to comment.