Skip to content

Commit

Permalink
avoid possible CCE when hg4idea plugin disabled. fix #592
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-zhuravlev committed Aug 2, 2019
1 parent 7f04794 commit aca47b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Expand Up @@ -41,6 +41,7 @@
import mobi.hsz.idea.gitignore.lang.kind.GitLanguage;
import mobi.hsz.idea.gitignore.lang.kind.MercurialLanguage;
import mobi.hsz.idea.gitignore.settings.IgnoreSettings;
import mobi.hsz.idea.gitignore.util.Utils;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -181,9 +182,9 @@ public void fileOpened(@NotNull final FileEditorManager source, @NotNull final V
@Nullable
private IgnoreLanguage determineIgnoreLanguage(@NotNull VirtualFile file, FileType fileType) {
FileTypeRegistry typeRegistry = FileTypeRegistry.getInstance();
if (typeRegistry.isFileOfType(file, GitIgnoreFileType.INSTANCE)) {
if (Utils.isGitPluginEnabled() && typeRegistry.isFileOfType(file, GitIgnoreFileType.INSTANCE)) {
return GitLanguage.INSTANCE;
} else if (typeRegistry.isFileOfType(file, HgIgnoreFileType.INSTANCE)) {
} else if (Utils.isMercurialPluginEnabled() && typeRegistry.isFileOfType(file, HgIgnoreFileType.INSTANCE)) {
return MercurialLanguage.INSTANCE;
} else if (fileType instanceof IgnoreFileType) {
return ((IgnoreFileType) fileType).getIgnoreLanguage();
Expand Down
9 changes: 9 additions & 0 deletions src/mobi/hsz/idea/gitignore/util/Utils.java
Expand Up @@ -386,6 +386,15 @@ public static boolean isGitPluginEnabled() {
return isPluginEnabled("Git4Idea");
}

/**
* Checks if Mercurial plugin is enabled.
*
* @return Mercurial plugin is enabled
*/
public static boolean isMercurialPluginEnabled() {
return isPluginEnabled("hg4idea");
}

/**
* Resolves user directory with the <code>user.home</code> property.
*
Expand Down

0 comments on commit aca47b9

Please sign in to comment.