Skip to content

Commit

Permalink
Avoid NullPointerException when the max_colors capability is null.
Browse files Browse the repository at this point in the history
This happened when setting TERM=vt100.
  • Loading branch information
PerBothner committed Oct 30, 2016
1 parent e61e4da commit 82b7d28
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/org/jline/utils/AttributedCharSequence.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public String toAnsi() {
public String toAnsi(Terminal terminal) {
StringBuilder sb = new StringBuilder();
int style = 0;
boolean color256 = (terminal != null && terminal.getNumericCapability(Capability.max_colors) >= 256);
Integer max_colors = terminal == null ? null
: terminal.getNumericCapability(Capability.max_colors);
boolean color256 = max_colors != null && max_colors >= 256;
for (int i = 0; i < length(); i++) {
char c = charAt(i);
int s = styleCodeAt(i) & ~F_HIDDEN; // The hidden flag does not change the ansi styles
Expand Down

0 comments on commit 82b7d28

Please sign in to comment.