Don't detect indents and show notifications in read-only files

This commit is contained in:
Rustam Vishnyakov
2018-07-10 18:19:01 +03:00
parent d7e2efc0c0
commit 6198c06198
2 changed files with 2 additions and 3 deletions
@@ -32,7 +32,6 @@ import com.intellij.openapi.editor.Document;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiCompiledFile;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import com.intellij.testFramework.LightVirtualFile;
@@ -114,7 +113,7 @@ public class DetectableIndentOptionsProvider extends FileIndentOptionsProvider {
}
private boolean isEnabled(@NotNull CodeStyleSettings settings, @NotNull PsiFile file) {
if (file instanceof PsiCompiledFile || file.getFileType() == ScratchFileType.INSTANCE) return false;
if (!(file.isWritable()) || file.getFileType() == ScratchFileType.INSTANCE) return false;
if (ApplicationManager.getApplication().isUnitTestMode()) {
return myIsEnabledInTest;
}
@@ -40,7 +40,7 @@ public class CodeStyleStatusBarWidget extends EditorBasedStatusBarPopup implemen
protected WidgetState getWidgetState(@Nullable VirtualFile file) {
if (file == null) return WidgetState.HIDDEN;
PsiFile psiFile = getPsiFile();
if (psiFile == null) return WidgetState.HIDDEN;
if (psiFile == null || !psiFile.isWritable()) return WidgetState.HIDDEN;
IndentOptions indentOptions = CodeStyle.getIndentOptions(psiFile);
IndentOptions projectIndentOptions = CodeStyle.getSettings(myProject).getLanguageIndentOptions(psiFile.getLanguage());
FileIndentOptionsProvider provider = findProvider(file, indentOptions);