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 committed Jul 8, 2024
1 parent 0e79c18 commit 88357bc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,10 @@ private void repositionTextSelection() {
}

private void positionToPart() {
if (isInvalidTargetShell()) {
close();
return;
}
getShell().requestLayout();
if (!(targetPart instanceof StatusTextEditor textEditor)) {
return;
Expand All @@ -833,6 +837,17 @@ private void positionToPart() {
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
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ private void showDialog() {
}

private void showOverlayInEditor() {
if (overlay == null) {
if (shouldCreateNewOverlay()) {
Shell shellToUse = null;

if (fShell == null) {
Expand All @@ -431,6 +431,10 @@ private void showOverlayInEditor() {
overlay.getShell().addDisposeListener(__ -> removeDialogPreferenceListener());
}

private boolean shouldCreateNewOverlay() {
return overlay == null || overlay.getShell() == null || overlay.getShell().isDisposed();
}

@Override
public void update() {

Expand Down

0 comments on commit 88357bc

Please sign in to comment.