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 Jun 22, 2024
1 parent 160dfa8 commit 7ddf9d7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ private void showDialog() {
}

private void showOverlayInEditor() {
if (overlay == null) {
if (overlay == null || !overlay.isOverlayOpen()) {
Shell shellToUse = null;

if (fShell == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,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 @@ -763,11 +767,18 @@ private void repositionTextSelection() {
}

private void positionToPart() {
getShell().requestLayout();
if (isInvalidTargetPart()) {
return;
}
if (isInvalidShell()) {
close();
return;
}
if (!(targetPart instanceof StatusTextEditor)) {
return;
}

getShell().requestLayout();
StatusTextEditor textEditor = (StatusTextEditor) targetPart;
Control targetWidget = textEditor.getSourceViewer().getTextWidget();
if (!okayToUse(targetWidget)) {
Expand All @@ -790,6 +801,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 String getFindString() {
return searchBar.getText();
}
Expand Down Expand Up @@ -863,4 +885,8 @@ private static boolean okayToUse(Widget widget) {
public void setPositionToTop(boolean shouldPositionOverlayOnTop) {
positionAtTop = shouldPositionOverlayOnTop;
}

public boolean isOverlayOpen() {
return overlayOpen;
}
}

0 comments on commit 7ddf9d7

Please sign in to comment.