Add padding for start line
* Add padding for start line
when end line has more digits.
* Another case
@@ -255,12 +255,14 @@ public class KException implements Serializable, HasLocation {
sourceText.append(StringUtils.repeat('~', firstLine.length() - location.startColumn()));
}
sourceText.append("\n\t");
- sourceText.append(String.valueOf(location.startLine()) + " |\t");
+ int padding = String.valueOf(location.endLine()).length() - String.valueOf(location.startLine()).length();
+ sourceText.append(StringUtils.repeat(' ', padding) + String.valueOf(location.startLine()) + " |\t");
sourceText.append(firstLine);
if (errorLineCount == 3) {
sourceText.append("\n\t");
- sourceText.append(String.valueOf(location.startLine() + 1) + " |\t");
+ int padding2 = String.valueOf(location.endLine()).length() - String.valueOf(location.startLine() + 1).length();
+ sourceText.append(StringUtils.repeat(' ', padding2) + String.valueOf(location.startLine() + 1) + " |\t");
Stream secondline = Files.lines(Paths.get(getSource().source()));
sourceText.append((String) secondline.skip(location.startLine()).findFirst().get());
} else if (errorLineCount > 3) {
