Skip to content

Commit f6332a3

Browse files
committed
Fix bug with errors for snippets without context
1 parent c52b4ec commit f6332a3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

scaladoc/src/dotty/tools/scaladoc/snippets/FlexmarkSnippetProcessor.scala

+7-2
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,14 @@ object FlexmarkSnippetProcessor:
6767

6868
val fullSnippet = Seq(snippetImports, snippet).mkString("\n").trim
6969
val snippetCompilationResult = cf(fullSnippet, lineOffset, argOverride) match {
70-
case result if !withContext =>
70+
case Some(result @ SnippetCompilationResult(wrapped, _, _, messages)) if !withContext =>
7171
node.setContentString(fullSnippet)
72-
result
72+
val innerLineOffset = wrapped.innerLineOffset
73+
Some(result.copy(messages = result.messages.map {
74+
case m @ SnippetCompilerMessage(Some(pos), _, _) =>
75+
m.copy(position = Some(pos.copy(relativeLine = pos.relativeLine - innerLineOffset)))
76+
case m => m
77+
}))
7378
case result@Some(SnippetCompilationResult(wrapped, _, _, _)) =>
7479
node.setContentString(wrapped.snippet)
7580
result

0 commit comments

Comments
 (0)