public void ContinueUndoGroup() { var doc = new TextDocument(); doc.Insert(0, "a"); doc.UndoStack.StartContinuedUndoGroup(); doc.Insert(1, "b"); doc.UndoStack.EndUndoGroup(); doc.UndoStack.Undo(); Assert.AreEqual("", doc.Text); }
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); }
public void ContinueEmptyUndoGroup_WithOptionalEntries() { var doc = new TextDocument(); doc.Insert(0, "a"); doc.UndoStack.StartUndoGroup(); doc.UndoStack.PushOptional(new StubUndoableAction()); doc.UndoStack.EndUndoGroup(); doc.UndoStack.StartContinuedUndoGroup(); doc.Insert(1, "b"); doc.UndoStack.EndUndoGroup(); doc.UndoStack.Undo(); Assert.AreEqual("a", doc.Text); }
public void TestLinesInserted() { document.Insert(0, "x\ny\n"); heightTree.SetHeight(document.Lines[0], 100); heightTree.SetHeight(document.Lines[1], 1000); heightTree.SetHeight(document.Lines[2], 10000); CheckHeights(); }
public void BackwardChanges() { TextDocument document = new TextDocument("initial text"); ITextSource snapshot1 = document.CreateSnapshot(); document.Replace(0, 7, "nw"); document.Insert(1, "e"); ITextSource snapshot2 = document.CreateSnapshot(); Assert.AreEqual(1, snapshot2.Version.CompareAge(snapshot1.Version)); TextChangeEventArgs[] arr = snapshot2.Version.GetChangesTo(snapshot1.Version).ToArray(); Assert.AreEqual(2, arr.Length); Assert.AreEqual("", arr[0].InsertedText.Text); Assert.AreEqual("initial", arr[1].InsertedText.Text); Assert.AreEqual("initial text", snapshot1.Text); Assert.AreEqual("new text", snapshot2.Text); }
public void InsertInCollapsedSection() { CollapsedLineSection sec1 = heightTree.CollapseText(document.GetLineByNumber(4), document.GetLineByNumber(6)); document.Insert(document.GetLineByNumber(5).Offset, "a\nb\nc"); for (int i = 1; i < 4; i++) { Assert.IsFalse(heightTree.GetIsCollapsed(i)); } for (int i = 4; i <= 8; i++) { Assert.IsTrue(heightTree.GetIsCollapsed(i)); } for (int i = 9; i <= 12; i++) { Assert.IsFalse(heightTree.GetIsCollapsed(i)); } CheckHeights(); }
public void InsertInEmptyDocument() { document.Insert(0, "a"); Assert.AreEqual(document.LineCount, 1); DocumentLine line = document.GetLineByNumber(1); Assert.AreEqual("a", document.GetText(line)); }