Skip to content

Commit d9ff93d

Browse files
authored
Merge pull request #182 from SeeSharpSoft/fb_fix_change_separator_action
Fix change separator action
2 parents aecc94d + 7e5a106 commit d9ff93d

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/main/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvDefaultSeparatorAction.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public boolean isSelected(@NotNull AnActionEvent anActionEvent) {
2222
if (psiFile == null) {
2323
return false;
2424
}
25-
return CsvHelper.getValueSeparator(psiFile) == null;
25+
return !CsvHelper.hasValueSeparatorAttribute(psiFile);
2626
}
2727

2828
@Override
@@ -31,7 +31,6 @@ public void setSelected(@NotNull AnActionEvent anActionEvent, boolean selected)
3131
if (psiFile == null) {
3232
return;
3333
}
34-
3534
CsvFileAttributes.getInstance(psiFile.getProject()).resetValueSeparator(psiFile);
3635
FileContentUtilCore.reparseFiles(psiFile.getVirtualFile());
3736

src/main/java/net/seesharpsoft/intellij/plugins/csv/components/CsvFileAttributes.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,9 @@ public void resetValueSeparator(@NotNull PsiFile psiFile) {
120120

121121
public @NotNull
122122
CsvValueSeparator getValueSeparator(Project project, VirtualFile virtualFile) {
123-
if (project == null || virtualFile == null) {
123+
if (project == null || virtualFile == null || !(virtualFile.getFileType() instanceof LanguageFileType)) {
124124
return CsvEditorSettings.getInstance().getDefaultValueSeparator();
125125
}
126-
assert(virtualFile.getFileType() instanceof LanguageFileType);
127126
Language language = ((LanguageFileType) virtualFile.getFileType()).getLanguage();
128127
if (language instanceof CsvSeparatorHolder) {
129128
return ((CsvSeparatorHolder) language).getSeparator();

0 commit comments

Comments
 (0)