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 41e4727
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,10 @@ public boolean close() {

@Override
public int open() {
super.open();
if (!okayToUse(getShell())) {
return Window.CANCEL;
}
int returnCode = Window.OK;
if (!overlayOpen) {
returnCode = super.open();
Expand Down Expand Up @@ -813,6 +817,10 @@ private void repositionTextSelection() {
}

private void positionToPart() {
if (isInvalidShell()) {
close();
return;
}
getShell().requestLayout();
if (!(targetPart instanceof StatusTextEditor textEditor)) {
return;
Expand All @@ -833,6 +841,17 @@ private void positionToPart() {
repositionTextSelection();
}

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

private boolean isInvalidShell() {
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 Expand Up @@ -954,4 +973,7 @@ private void removeSearchScope() {
findReplaceLogic.activate(SearchOptions.GLOBAL);
searchInSelectionButton.setSelection(false);
}
public boolean isOverlayOpen() {
return overlayOpen;
}
}
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 (overlay == null || !overlay.isOverlayOpen()) {
Shell shellToUse = null;

if (fShell == null) {
Expand Down

0 comments on commit 41e4727

Please sign in to comment.