search/replace: right readonly files handling.

This commit is contained in:
andrey zaytsev
2011-04-08 20:21:03 +04:00
parent e7d45a1176
commit 86e4bf6414
3 changed files with 4 additions and 5 deletions
@@ -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) {
@@ -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(),
@@ -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());
}
}