@@ -243,14 +243,28 @@ trait MessageRendering {
243
243
given Level = Level (level)
244
244
given Offset = Offset (maxLineNumber.toString.length + 2 )
245
245
val sb = StringBuilder ()
246
- val posString = posStr(pos, msg, diagnosticLevel(dia))
246
+ def adjust (pos : SourcePosition ): SourcePosition =
247
+ if pos.span.isSynthetic
248
+ && pos.span.isZeroExtent
249
+ && pos.span.exists
250
+ && pos.span.start == pos.source.length
251
+ && pos.source(pos.span.start - 1 ) == '\n '
252
+ then
253
+ pos.withSpan(pos.span.shift(- 1 ))
254
+ else
255
+ pos
256
+ val adjusted = adjust(pos)
257
+ val posString = posStr(adjusted, msg, diagnosticLevel(dia))
247
258
if (posString.nonEmpty) sb.append(posString).append(EOL )
248
259
if (pos.exists) {
249
260
val pos1 = pos.nonInlined
250
261
if (pos1.exists && pos1.source.file.exists) {
251
- val (srcBefore, srcAfter, offset) = sourceLines(pos1)
252
- val marker = positionMarker(pos1)
253
- val err = errorMsg(pos1, msg.message)
262
+ val readjusted =
263
+ if pos1 == pos then adjusted
264
+ else adjust(pos1)
265
+ val (srcBefore, srcAfter, offset) = sourceLines(readjusted)
266
+ val marker = positionMarker(readjusted)
267
+ val err = errorMsg(readjusted, msg.message)
254
268
sb.append((srcBefore ::: marker :: err :: srcAfter).mkString(EOL ))
255
269
256
270
if inlineStack.nonEmpty then
0 commit comments