public CreateAnchor ( int offset ) : |
||
offset | int | |
return |
public AnchorSegment(TextDocument document, int offset, int length) { Debug.Assert(document != null); this.start = document.CreateAnchor(offset); this.start.SurviveDeletion = true; this.end = document.CreateAnchor(offset + length); this.end.SurviveDeletion = true; }
/// <summary> /// Creates a new AnchorSegment that creates new anchors. /// </summary> public AnchorSegment(TextDocument document, int offset, int length) { if (document == null) { throw new ArgumentNullException("document"); } this.start = document.CreateAnchor(offset); this.start.SurviveDeletion = true; this.start.MovementType = AnchorMovementType.AfterInsertion; this.end = document.CreateAnchor(offset + length); this.end.SurviveDeletion = true; this.start.MovementType = AnchorMovementType.BeforeInsertion; }
public void AnchorInEmptyDocument() { TextAnchor a1 = document.CreateAnchor(0); TextAnchor a2 = document.CreateAnchor(0); a1.MovementType = AnchorMovementType.BeforeInsertion; a2.MovementType = AnchorMovementType.AfterInsertion; Assert.AreEqual(0, a1.Offset); Assert.AreEqual(0, a2.Offset); document.Insert(0, "x"); Assert.AreEqual(0, a1.Offset); Assert.AreEqual(1, a2.Offset); }