Add property tests for PositionMapping (#2265)

This commit is contained in:
Moritz Kiefer 2019-07-23 17:05:44 +02:00 committed by Gary Verhaegen
parent 61c37a93b3
commit 904ab6d6fa

View File

@ -41,8 +41,8 @@ applyChange posMapping _ = posMapping
toCurrent :: Range -> T.Text -> Position -> Maybe Position
toCurrent (Range (Position startLine startColumn) (Position endLine endColumn)) t (Position line column)
| line < startLine || line == startLine && column <= startColumn =
-- Position is before the change and thereby unchanged
| line < startLine || line == startLine && column < startColumn =
-- Position is before the change and thereby unchanged.
Just $ Position line column
| line > endLine || line == endLine && column >= endColumn =
-- Position is after the change so increase line and column number
@ -63,7 +63,7 @@ toCurrent (Range (Position startLine startColumn) (Position endLine endColumn))
fromCurrent :: Range -> T.Text -> Position -> Maybe Position
fromCurrent (Range (Position startLine startColumn) (Position endLine endColumn)) t (Position line column)
| line < startLine || line == startLine && column <= startColumn =
| line < startLine || line == startLine && column < startColumn =
-- Position is before the change and thereby unchanged
Just $ Position line column
| line > newEndLine || line == newEndLine && column >= newEndColumn =