Use tab-expanded column numbers when formatting DSL errors

This commit is contained in:
Riccardo Azzolini 2019-08-12 18:40:17 +02:00
parent b3f2ad82d0
commit 804fee4db0
1 changed files with 5 additions and 1 deletions

View File

@ -42,7 +42,11 @@ public class FilesErrorsFormatter {
final List<LineMap.Line> spannedLines = lines.getSpannedLines(error.getPosition(), error.getLength());
final LineMap.Line firstLine = spannedLines.get(0);
final int column = error.getPosition() - firstLine.getStartPosition() + 1;
final int positionInFirstLine = error.getPosition() - firstLine.getStartPosition();
final TabExpandedString expandedFirstLine = new TabExpandedString(firstLine.getText(), TAB_WIDTH);
// When computing the column number, each tab character is counted as the number of spaces it expands to
final int column = 1 + expandedFirstLine.substringLength(0, positionInFirstLine);
builder.append(filePath).append(":")
.append(firstLine.getNumber()).append(":")