Skip to content

Commit

Permalink
ups
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Dec 10, 2023
1 parent 52e7ef3 commit 4679df0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/org/mozilla/javascript/ast/AstNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ public abstract class AstNode extends Node implements Comparable<AstNode> {
operatorNames.put(Token.VOID, "void");

StringBuilder sb = new StringBuilder();
for (int i = 0; i <= MAX_INDENT; i++) {
INDENTATIONS[0] = sb.toString();
for (int i = 1; i <= MAX_INDENT; i++) {
sb.append(" ");
INDENTATIONS[i] = sb.toString();
}
Expand Down Expand Up @@ -308,7 +309,8 @@ public String toSource() {
* @param indent the number of indentation steps
*/
public String makeIndent(int indent) {
return INDENTATIONS[Math.min(MAX_INDENT, indent)];
indent = Math.min(MAX_INDENT, Math.max(0, indent));
return INDENTATIONS[indent];
}

/** Returns a short, descriptive name for the node, such as "ArrayComprehension". */
Expand Down

0 comments on commit 4679df0

Please sign in to comment.