mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
search/replace: right readonly files handling.
This commit is contained in:
@@ -67,7 +67,7 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean okToWrite(Editor e) {
|
||||
public static boolean ensureOkToWrite(Editor e) {
|
||||
final PsiFile psiFile = PsiDocumentManager.getInstance(e.getProject()).getPsiFile(e.getDocument());
|
||||
boolean okWritable;
|
||||
if (psiFile != null) {
|
||||
|
||||
+2
-2
@@ -195,7 +195,7 @@ public class LivePreviewControllerBase implements LivePreview.Delegate, FindUtil
|
||||
@Nullable
|
||||
@Override
|
||||
public TextRange performReplace(final LiveOccurrence occurrence, final String replacement, final Editor editor) {
|
||||
if (myReplaceDenied || !Utils.okToWrite(editor)) return null;
|
||||
if (myReplaceDenied || !Utils.ensureOkToWrite(editor)) return null;
|
||||
TextRange range = occurrence.getPrimaryRange();
|
||||
FindModel findModel = mySearchResults.getFindModel();
|
||||
TextRange result = null;
|
||||
@@ -217,7 +217,7 @@ public class LivePreviewControllerBase implements LivePreview.Delegate, FindUtil
|
||||
|
||||
@Override
|
||||
public void performReplaceAll(Editor e) {
|
||||
if (!Utils.okToWrite(e)) return;
|
||||
if (!Utils.ensureOkToWrite(e)) return;
|
||||
if (mySearchResults.getFindModel() != null) {
|
||||
FindUtil.replace(e.getProject(), e,
|
||||
mySearchResults.getFindModel().isGlobal() ? 0 : mySearchResults.getEditor().getSelectionModel().getSelectionStart(),
|
||||
|
||||
+1
-2
@@ -20,7 +20,6 @@ import com.intellij.find.EditorSearchComponent;
|
||||
import com.intellij.find.FindManager;
|
||||
import com.intellij.find.FindModel;
|
||||
import com.intellij.find.FindUtil;
|
||||
import com.intellij.find.editorHeaderActions.Utils;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
@@ -70,7 +69,7 @@ public class IncrementalFindAction extends EditorAction {
|
||||
|
||||
public boolean isEnabled(Editor editor, DataContext dataContext) {
|
||||
Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(editor.getComponent()));
|
||||
return project != null && !editor.isOneLineMode() && (!myReplace || Utils.okToWrite(editor));
|
||||
return project != null && !editor.isOneLineMode() && (!myReplace || editor.getDocument().isWritable());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user