Skip to content

Commit ead67da

Browse files
committed
Tweak error generation.
1 parent 63b8ebe commit ead67da

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/util/terminal.d

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ void outputCaretDiagnostics(FullLocation location, string fixHint) {
4444
end = cast(uint) content.length;
4545
}
4646

47+
// Trim end of line if apropriate.
48+
while (end > start) {
49+
end--;
50+
51+
auto c = content[end - 1];
52+
if (c != '\r' && c != '\n') {
53+
end++;
54+
break;
55+
}
56+
}
57+
58+
// Extend the range up to the end of the line.
4759
while (end < content.length) {
4860
auto c = content[end];
4961
if (c == '\0' || c == '\r' || c == '\n') {
@@ -56,7 +68,7 @@ void outputCaretDiagnostics(FullLocation location, string fixHint) {
5668
auto line = content[start .. end];
5769
uint index = offset - start;
5870

59-
// Multi line location
71+
// Multi line location.
6072
if (index < line.length && index + length > line.length) {
6173
length = cast(uint) line.length - index;
6274
}

0 commit comments

Comments
 (0)