Skip to content

Commit 5d4aada

Browse files
committed
Fix "run on multiple files" not working when the file is not a text file
Fixes #129
1 parent 043b373 commit 5d4aada

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.2.3
2+
* Fix "run on multiple files" not working when the file is not a text file #129
3+
14
## 1.2.2
25
* Workaround scaling problem on "New UI" [#26](https://github.com/xdev-software/intellij-plugin-template/issues/26)
36

src/main/java/software/xdev/saveactions/core/component/Engine.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ private boolean isPsiFileEligible(final Project project, final PsiFile psiFile)
114114
return psiFile != null
115115
&& this.isProjectValid(project)
116116
&& this.isPsiFileValid(psiFile)
117+
&& this.hasPsiFileText(psiFile)
117118
&& this.isPsiFileFresh(psiFile)
118119
&& this.isPsiFileInProject(project, psiFile)
119120
&& this.isPsiFileNoError(project, psiFile)
@@ -189,6 +190,16 @@ private boolean isPsiFileValid(final PsiFile psiFile)
189190
return valid;
190191
}
191192

193+
private boolean hasPsiFileText(final PsiFile psiFile)
194+
{
195+
final boolean valid = psiFile.getTextRange() != null;
196+
if(!valid)
197+
{
198+
LOGGER.info(String.format("File %s has no text.", psiFile));
199+
}
200+
return valid;
201+
}
202+
192203
boolean isIncludedAndNotExcluded(final String path)
193204
{
194205
return this.isIncluded(path) && !this.isExcluded(path);

0 commit comments

Comments
 (0)