File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -152,6 +152,8 @@ proc `$`*(self: DiffMapSnapshot): string =
152152 inc i
153153
154154proc toDiffPoint * (self: DiffMapChunkCursor , point: InputPoint ): DiffPoint =
155+ if not (point.row in self.startPos.src... self.endPos.src):
156+ return self.startPos.dst.diffPoint
155157 assert point.row in self.startPos.src... self.endPos.src
156158 # if self.startPos.dst == self.endPos.dst:
157159 # return diffPoint(self.startPos.dst)
Original file line number Diff line number Diff line change @@ -678,17 +678,20 @@ proc next*(self: var WrapChunkIterator): Option[WrapChunk] =
678678 dst: self.wrapMapCursor.startPos.dst... self.wrapMapCursor.endPos.dst)
679679
680680 if currentChunk.endOutputPoint <= map.src.b:
681- self.localOffset = currentChunk.len
681+ self.localOffset = max (currentChunk.len, 0 )
682+ if self.localOffset < startOffset:
683+ self.wrapChunk = WrapChunk (inputChunk: currentChunk, wrapPoint: self.wrapPoint).some
684+ return self.wrapChunk
682685 assert self.localOffset >= 0
683686 var newChunk = currentChunk.split (startOffset).suffix.split (self.localOffset - startOffset).prefix
684687 newChunk.outputPoint = currentInputPoint
685688 self.wrapChunk = WrapChunk (inputChunk: newChunk, wrapPoint: self.wrapPoint).some
686689
687690 else :
688- self.localOffset = map.src.b.column.int - currentChunk.outputPoint.column.int
689- if self.localOffset < 0 :
691+ self.localOffset = max ( map.src.b.column.int - currentChunk.outputPoint.column.int , 0 )
692+ if self.localOffset < startOffset :
690693 self.wrapChunk = WrapChunk (inputChunk: currentChunk, wrapPoint: self.wrapPoint).some
691- return
694+ return self.wrapChunk
692695
693696 assert self.localOffset >= 0
694697 var newChunk = currentChunk.split (startOffset).suffix.split (self.localOffset - startOffset).prefix
You can’t perform that action at this time.
0 commit comments