コード例 #1
0
ファイル: UndoStackTests.cs プロジェクト: wuzlai/AvaloniaEdit
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: UndoStackTests.cs プロジェクト: wuzlai/AvaloniaEdit
        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);
        }
コード例 #4
0
 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();
 }
コード例 #5
0
        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);
        }
コード例 #6
0
        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();
        }
コード例 #7
0
        public void InsertInEmptyDocument()
        {
            document.Insert(0, "a");
            Assert.AreEqual(document.LineCount, 1);
            DocumentLine line = document.GetLineByNumber(1);

            Assert.AreEqual("a", document.GetText(line));
        }