File tree Expand file tree Collapse file tree 1 file changed +18
-15
lines changed
presentation-compiler/src/main/dotty/tools/pc Expand file tree Collapse file tree 1 file changed +18
-15
lines changed Original file line number Diff line number Diff line change @@ -319,21 +319,24 @@ object EndMarker:
319319 implicit ct : Context
320320 ): Option [SourcePosition ] =
321321 val name = df.name.toString().stripSuffix(" $" )
322- val endMarkerLine =
323- sourceText.slice(df.span.start, df.span.end).split('\n ' ).last
324- val index = endMarkerLine.length() - name.length()
325- if index < 0 then None
326- else
327- val (possiblyEndMarker, possiblyEndMarkerName) =
328- endMarkerLine.splitAt(index)
329- Option .when(
330- possiblyEndMarkerName == name &&
331- endMarkerRegex.matches(possiblyEndMarker)
332- )(
333- pos
334- .withStart(df.span.end - name.length())
335- .withEnd(df.span.end)
336- )
322+ val lines = sourceText.slice(df.span.start, df.span.end).split('\n ' )
323+
324+ if lines.nonEmpty then
325+ val endMarkerLine = lines.last
326+ val index = endMarkerLine.length() - name.length()
327+ if index < 0 then None
328+ else
329+ val (possiblyEndMarker, possiblyEndMarkerName) =
330+ endMarkerLine.splitAt(index)
331+ Option .when(
332+ possiblyEndMarkerName == name &&
333+ endMarkerRegex.matches(possiblyEndMarker)
334+ )(
335+ pos
336+ .withStart(df.span.end - name.length())
337+ .withEnd(df.span.end)
338+ )
339+ else None
337340 end getPosition
338341end EndMarker
339342
You can’t perform that action at this time.
0 commit comments