Skip to content

Commit

Permalink
SystemHighlighter fixed NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Nov 29, 2020
1 parent 924d8ff commit 0e5d510
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -27,6 +27,7 @@ public class SystemHighlighter extends DefaultHighlighter {
private final SyntaxHighlighter commandHighlighter;
private final SyntaxHighlighter argsHighlighter;
private final SyntaxHighlighter langHighlighter;
private final SystemRegistry systemRegistry;
private Pattern errorPattern;
private int errorIndex = -1;

Expand All @@ -35,6 +36,7 @@ public SystemHighlighter(SyntaxHighlighter commandHighlighter, SyntaxHighlighter
this.commandHighlighter = commandHighlighter;
this.argsHighlighter = argsHighlighter;
this.langHighlighter = langHighlighter;
this.systemRegistry = SystemRegistry.get();
}

@Override
Expand Down Expand Up @@ -64,7 +66,7 @@ private AttributedString systemHighlight(Parser parser, String buffer) {
AttributedString out;
if (buffer.trim().isEmpty()) {
out = new AttributedStringBuilder().append(buffer).toAttributedString();
} else if (SystemRegistry.get().isCommandOrScript(parser.getCommand(buffer.trim().split("\\s+")[0]))) {
} else if (systemRegistry.isCommandOrScript(parser.getCommand(buffer.trim().split("\\s+")[0]))) {
if (commandHighlighter != null || argsHighlighter != null) {
int idx = -1;
boolean cmdFound = false;
Expand Down

0 comments on commit 0e5d510

Please sign in to comment.