Skip to content

Commit

Permalink
correct post-splice shift ZincWorkerImpl's reporter
Browse files Browse the repository at this point in the history
  • Loading branch information
bishabosha committed Oct 14, 2024
1 parent 029f1bf commit 57665a0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions scalalib/worker/src/mill/scalalib/worker/ZincWorkerImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -735,11 +735,16 @@ object ZincWorkerImpl {
val splicedMarkerStartLine = lines.indexWhere(_.startsWith(splicedCodeStartMarker))
val splicedMarkerLine = lines.indexWhere(_.startsWith(splicedCodeEndMarker))
val existsSplicedMarker = splicedMarkerStartLine >= 0 && splicedMarkerLine >= 0
val splicedMarkerLineDiff = markerLine + (splicedMarkerLine - splicedMarkerStartLine + 1) + 1
val splicedMarkerLineDiff = markerLine + (splicedMarkerLine - splicedMarkerStartLine + 1)

val topWrapperLen = lines.take(markerLine + 1).map(_.length).sum
val splicedMarkerLen =
if existsSplicedMarker then lines.take(splicedMarkerLine + 1).map(_.length).sum
val (splicedMarkerStartLen, splicedMarkerLen) =
if existsSplicedMarker then
lines.take(splicedMarkerStartLine + 1).map(_.length).sum
-> lines.take(splicedMarkerLine + 1).map(_.length).sum
else (-1, -1)
val splicedMarkerDiff =
if existsSplicedMarker then topWrapperLen + (splicedMarkerStartLen - splicedMarkerLen + 1)
else -1

val originPath = Some(adjustedFile)
Expand All @@ -766,7 +771,7 @@ object ZincWorkerImpl {

val (baseLine, baseOffset) =
if postSplice(startOffset) || postSplice(offset) then
(splicedMarkerLineDiff, splicedMarkerLen)
(splicedMarkerLineDiff, splicedMarkerDiff)
else
(markerLine, topWrapperLen)

Expand Down

0 comments on commit 57665a0

Please sign in to comment.