[search] restore the use of the editor selection in the Find in Files popup (IDEA-314095)

GitOrigin-RevId: 6bdcb21888dd863ab8e5c2f6a638f3350df08aff
This commit is contained in:
Bas Leijdekkers
2023-02-25 00:20:49 +01:00
committed by intellij-monorepo-bot
parent 89e3b09088
commit 4a89df730e
8 changed files with 17 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
--- FIND MODEL ---
myStringToFind = ''
myStringToFind = null
myStringToReplace = ''
isReplaceState = false
isWholeWordsOnly = false

View File

@@ -1,5 +1,5 @@
--- FIND MODEL ---
myStringToFind = ''
myStringToFind = null
myStringToReplace = ''
isReplaceState = false
isWholeWordsOnly = false

View File

@@ -1,5 +1,5 @@
--- FIND MODEL ---
myStringToFind = ''
myStringToFind = null
myStringToReplace = ''
isReplaceState = false
isWholeWordsOnly = false

View File

@@ -1,5 +1,5 @@
--- FIND MODEL ---
myStringToFind = ''
myStringToFind = null
myStringToReplace = ''
isReplaceState = false
isWholeWordsOnly = false

View File

@@ -1,5 +1,5 @@
--- FIND MODEL ---
myStringToFind = ''
myStringToFind = null
myStringToReplace = ''
isReplaceState = false
isWholeWordsOnly = false

View File

@@ -1,5 +1,5 @@
--- FIND MODEL ---
myStringToFind = ''
myStringToFind = null
myStringToReplace = ''
isReplaceState = false
isWholeWordsOnly = false

View File

@@ -54,7 +54,7 @@ public class FindModel extends UserDataHolderBase implements Cloneable {
}
}
private String myStringToFind = "";
private String myStringToFind = null;
private String myStringToReplace = "";
private boolean isSearchHighlighters;
private boolean isReplaceState;
@@ -236,7 +236,11 @@ public class FindModel extends UserDataHolderBase implements Cloneable {
*/
@NotNull
public String getStringToFind() {
return myStringToFind;
return (myStringToFind == null) ? "" : myStringToFind;
}
public boolean hasStringToFind() {
return myStringToFind != null;
}
/**
@@ -617,7 +621,7 @@ public class FindModel extends UserDataHolderBase implements Cloneable {
@Override
public String toString() {
return "--- FIND MODEL ---\n" +
"myStringToFind = '" + myStringToFind + "'\n" +
"myStringToFind = " + (myStringToFind == null ? "null\n" : "'" + myStringToFind + "'\n") +
"myStringToReplace = '" + myStringToReplace + "'\n" +
"isReplaceState = " + isReplaceState + "\n" +
"isWholeWordsOnly = " + isWholeWordsOnly + "\n" +

View File

@@ -1048,8 +1048,10 @@ public class FindPopupPanel extends JBPanel<FindPopupPanel> implements FindUI, D
}
header.fileMaskField.setEnabled(isThereFileFilter);
FindInProjectSettings findInProjectSettings = FindInProjectSettings.getInstance(myProject);
mySearchComponent.setText(findInProjectSettings.getMostRecentFindString());
myReplaceComponent.setText(findInProjectSettings.getMostRecentReplaceString());
String search = myModel.hasStringToFind() ? myModel.getStringToFind() : findInProjectSettings.getMostRecentFindString();
mySearchComponent.setText(search);
String replace = myModel.hasStringToFind() ? myModel.getStringToReplace() : findInProjectSettings.getMostRecentReplaceString();
myReplaceComponent.setText(replace);
updateControls();
updateScopeDetailsPanel();