Skip to content

Commit

Permalink
Viewer/Editor Fix for NPE when opening certain python files while cod…
Browse files Browse the repository at this point in the history
…e folding is enabled #983
  • Loading branch information
pskowronek authored and ahadas committed Jun 24, 2023
1 parent 03bec36 commit e2e1852
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,15 @@ void setSyntaxStyle(String syntaxStyleMimeType) {
public void setSyntaxStyle(AbstractFile file) {
String mimeType = FileTypeUtil.get().guessContentType(
new File(file.getCanonicalPath()), true);
textArea.setSyntaxEditingStyle(mimeType);

// TODO temporary fix with try/catch to address: https://github.com/mucommander/mucommander/issues/983, https://github.com/bobbylight/RSyntaxTextArea/issues/514
try {
textArea.setSyntaxEditingStyle(mimeType);
} catch (Exception e) {
LOGGER.error("Exception while trying to set syntax editing style - retrying with code folding disabled", e);
textArea.setCodeFoldingEnabled(false);
textArea.setSyntaxEditingStyle(mimeType);
}
if (syntaxChangeListener != null) {
syntaxChangeListener.accept(mimeType);
}
Expand Down

0 comments on commit e2e1852

Please sign in to comment.