From 4679df04d004f1552c0269f9e1d7021724e44b08 Mon Sep 17 00:00:00 2001 From: Ronald Brill Date: Sun, 10 Dec 2023 09:41:16 +0100 Subject: [PATCH] ups --- src/org/mozilla/javascript/ast/AstNode.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/org/mozilla/javascript/ast/AstNode.java b/src/org/mozilla/javascript/ast/AstNode.java index 9d534fff89..fa9cdfc04f 100644 --- a/src/org/mozilla/javascript/ast/AstNode.java +++ b/src/org/mozilla/javascript/ast/AstNode.java @@ -125,7 +125,8 @@ public abstract class AstNode extends Node implements Comparable { 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(); } @@ -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". */