public void SubtractSimple() { var textBuffer = CreateTextBuffer("A𠈓C"); var point = new SnapshotCodePoint(textBuffer.GetEndPoint()); AssertIt(point.Subtract(1), codePointInfo: CodePointInfo.SimpleCharacter, text: "C", position: 3); AssertIt(point.Subtract(2), codePointInfo: CodePointInfo.SurrogatePairHighCharacter, text: "𠈓", position: 1); AssertIt(point.Subtract(3), codePointInfo: CodePointInfo.SimpleCharacter, text: "A", position: 0); }
public void SubtractAcrossLines() { var textBuffer = CreateTextBuffer("cat", "dog"); var point1 = new SnapshotCodePoint(textBuffer.GetPointInLine(line: 1, column: 0)); var point2 = point1.Subtract(2); Assert.Equal(0, point2.Line.LineNumber); }
public void SubtractKeepsLineReference() { var textBuffer = CreateTextBuffer("cat", "dog"); var point = new SnapshotCodePoint(textBuffer.GetStartPoint().GetContainingLine(), 4); var line = point.Line; while (point.StartPosition > 0) { point = point.Subtract(1); Assert.Same(line, point.Line); } }