Skip to content

Commit

Permalink
Prevent negative indentLevel in target formatter (#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardZaydler authored Oct 23, 2024
1 parent 368e187 commit d88bf94
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Components/HighlightInput/formatQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export const formatQuery = (input: string | Iterable<string>) => {
} else if (token.value === "|") {
output += token.value + "\n";
} else if (token.value === ")" || token.value === "}") {
output = output.trimEnd() + "\n" + " ".repeat(indentLevel - 1) + token.value;
indentLevel--;
indentLevel = Math.max(indentLevel - 1, 0); // Prevent negative indentLevel
output = output.trimEnd() + "\n" + " ".repeat(indentLevel) + token.value;
} else if (token.value === ",") {
output += token.value + "\n" + " ".repeat(indentLevel);
} else if (token.type === "empty") {
Expand Down

0 comments on commit d88bf94

Please sign in to comment.