mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-102111 Keep search/replace words between files
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.find;
|
||||
|
||||
import com.intellij.execution.impl.ConsoleViewUtil;
|
||||
import com.intellij.find.editorHeaderActions.*;
|
||||
import com.intellij.find.impl.livePreview.LivePreviewController;
|
||||
import com.intellij.find.impl.livePreview.SearchResults;
|
||||
@@ -154,7 +155,7 @@ public class EditorSearchSession implements SearchSession,
|
||||
updateUIWithFindModel();
|
||||
mySearchResults.clear();
|
||||
updateResults(true);
|
||||
FindUtil.updateFindInFileModel(getProject(), myFindModel);
|
||||
FindUtil.updateFindInFileModel(getProject(), myFindModel, !ConsoleViewUtil.isConsoleViewEditor(editor));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -143,14 +143,20 @@ public class FindUtil {
|
||||
model.setPromptOnReplace(false);
|
||||
}
|
||||
|
||||
public static void updateFindInFileModel(@Nullable Project project, @NotNull FindModel with) {
|
||||
public static void updateFindInFileModel(@Nullable Project project, @NotNull FindModel with, boolean saveFindString) {
|
||||
FindModel model = FindManager.getInstance(project).getFindInFileModel();
|
||||
model.setCaseSensitive(with.isCaseSensitive());
|
||||
model.setWholeWordsOnly(with.isWholeWordsOnly());
|
||||
model.setRegularExpressions(with.isRegularExpressions());
|
||||
model.setSearchContext(with.getSearchContext());
|
||||
|
||||
if (saveFindString && !with.getStringToFind().isEmpty()) {
|
||||
model.setStringToFind(with.getStringToFind());
|
||||
}
|
||||
|
||||
if (with.isReplaceState()) {
|
||||
model.setPreserveCase(with.isPreserveCase());
|
||||
if (saveFindString) model.setStringToReplace(with.getStringToReplace());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -28,7 +28,6 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
|
||||
public class IncrementalFindAction extends EditorAction {
|
||||
public static class Handler extends EditorActionHandler {
|
||||
@@ -57,9 +56,14 @@ public class IncrementalFindAction extends EditorAction {
|
||||
model = new FindModel();
|
||||
model.copyFrom(findManager.getFindInFileModel());
|
||||
}
|
||||
FindUtil.configureFindModel(myReplace, editor, model, true);
|
||||
boolean consoleViewEditor = ConsoleViewUtil.isConsoleViewEditor(editor);
|
||||
FindUtil.configureFindModel(myReplace, editor, model, consoleViewEditor);
|
||||
EditorSearchSession.start(editor, model, project).getComponent()
|
||||
.requestFocusInTheSearchFieldAndSelectContent(project);
|
||||
if (!consoleViewEditor && editor.getSelectionModel().hasSelection()) {
|
||||
// selection is used as string to find without search model modification so save the pattern explicitly
|
||||
FindUtil.updateFindInFileModel(project, model, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user