Skip to content

Commit

Permalink
Account for offset string length in error message
Browse files Browse the repository at this point in the history
Summary: Adjust the spacing for the margin based on the size of the offset number string length.
  • Loading branch information
mrjameshamilton authored and jelle-dc committed Sep 13, 2024
1 parent 88378b4 commit db60200
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void printException(
.append("\n");
}
// print the erroneous instruction
int offset = offsetBuffer.peek();
String offset = String.valueOf(offsetBuffer.peek());
messageBuilder
.append(ANSI_CYAN)
.append(offset)
Expand All @@ -123,10 +123,11 @@ public void printException(
.append("\n");

String indicators = new String(new char[errorInstructionString.length()]).replace('\0', '^');
String margin = new String(new char[offset.length()]).replace('\0', ' ');
messageBuilder
.append(" ")
.append(margin)
.append(ANSI_CYAN)
.append("|")
.append(" |")
.append(ANSI_RESET)
.append(" ")
.append(ANSI_RED)
Expand Down

0 comments on commit db60200

Please sign in to comment.