From db60200d2dcaf29b0fd35b7b4ecb858666db747e Mon Sep 17 00:00:00 2001 From: James Hamilton Date: Wed, 11 Sep 2024 15:29:02 +0200 Subject: [PATCH] Account for offset string length in error message Summary: Adjust the spacing for the margin based on the size of the offset number string length. --- .../proguard/exception/InstructionExceptionFormatter.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/base/src/main/java/proguard/exception/InstructionExceptionFormatter.java b/base/src/main/java/proguard/exception/InstructionExceptionFormatter.java index 813caf4c8..34a7dafa9 100644 --- a/base/src/main/java/proguard/exception/InstructionExceptionFormatter.java +++ b/base/src/main/java/proguard/exception/InstructionExceptionFormatter.java @@ -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) @@ -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)