Example #1
0
        public void TestGetStartFoldingsGetStartFoldings()
        {
            Document document = new Mono.TextEditor.Document();

            document.Text =
                @"+[1
2
3
+[4
5
+[6
7]
8]
+[9
10
11]
12]
+[13
14]
15
16";
            var segments = GetFoldSegments(document);

            document.UpdateFoldSegments(segments, false);
            document.UpdateFoldSegments(segments, false);
            document.UpdateFoldSegments(segments, false);

            Assert.AreEqual(1, document.GetStartFoldings(1).Count());
            Assert.AreEqual(1, document.GetStartFoldings(4).Count());
            Assert.AreEqual(1, document.GetStartFoldings(6).Count());
            Assert.AreEqual(1, document.GetStartFoldings(9).Count());
            Assert.AreEqual(1, document.GetStartFoldings(13).Count());
        }
Example #2
0
        public void TestBug682466()
        {
            Document document = new Mono.TextEditor.Document();

            document.Text =
                @"0
1
2
+[3
4
5
6]
7
8
9
10";
            var segments = GetFoldSegments(document);

            document.UpdateFoldSegments(segments, false);
            Assert.AreEqual(true, document.FoldSegments.FirstOrDefault().IsFolded);
            segments             = GetFoldSegments(document);
            segments[0].IsFolded = false;
            document.UpdateFoldSegments(segments, false);
            Assert.AreEqual(5, document.LogicalToVisualLine(8));
        }
Example #3
0
        public void TestUpdateFoldSegmentBug()
        {
            Document document = new Mono.TextEditor.Document();

            document.Text =
                @"-[0
1
+[2
3
4
5
6
7
8
9
10]
11
]12
13
+[14
15
16
17
18
19
20
21
22]
23
24
25
26";
            var segments = GetFoldSegments(document);

            document.UpdateFoldSegments(segments, false);
            Assert.AreEqual(25, document.VisualToLogicalLine(9));
            Assert.AreEqual(3, document.FoldSegments.Count());
            segments.RemoveAt(1);


            document.UpdateFoldSegments(segments, false);

            Assert.AreEqual(2, document.FoldSegments.Count());
            Assert.AreEqual(17, document.LogicalToVisualLine(25));
            segments.RemoveAt(1);
            document.UpdateFoldSegments(segments, false);
            Assert.AreEqual(1, document.FoldSegments.Count());
            Assert.AreEqual(25, document.LogicalToVisualLine(25));
        }
Example #4
0
        public void TestUpdateFoldSegmentBug2()
        {
            Document document = new Mono.TextEditor.Document();

            document.Text =
                @"-[1
2
+[3
4]
5
+[6
7]
8
9
10
11
12
13
14]
15
16";
            var segments = GetFoldSegments(document);

            document.UpdateFoldSegments(segments, false);
            Assert.AreEqual(10, document.VisualToLogicalLine(8));
            Assert.AreEqual(3, document.FoldSegments.Count());
            int start = document.GetLine(2).Offset;
            int end   = document.GetLine(8).Offset;

            ((IBuffer)document).Remove(start, end - start);
            Assert.AreEqual(1, document.FoldSegments.Count());
            Assert.AreEqual(10, document.LogicalToVisualLine(10));
        }
Example #5
0
        public void TestVisualToLogicalLine()
        {
            Document document = new Mono.TextEditor.Document();

            document.Text =
                @"-[0
+[1
2
]3
4
+[5
+[6
+[7
8
]9
]10
]11
]12
13
+[14
15
]16
17";
            document.UpdateFoldSegments(GetFoldSegments(document), false);
            Assert.AreEqual(4, document.LogicalToVisualLine(12));
            Assert.AreEqual(6, document.LogicalToVisualLine(16));
            Assert.AreEqual(7, document.LogicalToVisualLine(17));
        }
Example #6
0
        public void TestIsFoldedUnsetFolded()
        {
            Document document = new Mono.TextEditor.Document();

            document.Text =
                @"-[1
2
3
+[4
5
+[6
7]
8]
-[9
10
11]
12]
-[13
14]
15
16";
            var segments = GetFoldSegments(document);

            document.UpdateFoldSegments(segments, false);
            Assert.AreEqual(11, document.LogicalToVisualLine(15));
            document.GetStartFoldings(6).First().IsFolded = false;
            document.GetStartFoldings(4).First().IsFolded = false;
            Assert.AreEqual(15, document.LogicalToVisualLine(15));
        }
Example #7
0
        public void TestUpdateFoldSegmentBug2()
        {
            Document document = new Mono.TextEditor.Document();

            document.Text =
                @"-[0
1
+[2
3]
4
+[5
6]
7
8
9
10
11
12
13]
14
15";
            var segments = GetFoldSegments(document);

            document.UpdateFoldSegments(segments, false);
            Assert.AreEqual(10, document.VisualToLogicalLine(8));
            int start = document.GetLine(2).Offset;
            int end   = document.GetLine(8).Offset;

            ((IBuffer)document).Remove(start, end - start);
            Assert.AreEqual(10, document.LogicalToVisualLine(10));
        }
Example #8
0
        public void TestLogicalToVisualLine()
        {
            Document document = new Mono.TextEditor.Document();

            document.Text =
                @"-[1
+[2
3
]4
5
+[6
+[7
+[8
9
]10
]11
]12
]13
14
+[15
16
]17
18";
            document.UpdateFoldSegments(GetFoldSegments(document), false);
            Assert.AreEqual(4, document.LogicalToVisualLine(12));
            Assert.AreEqual(6, document.LogicalToVisualLine(16));
            Assert.AreEqual(7, document.LogicalToVisualLine(17));
        }
Example #9
0
        public void TestVisualToLogicalLineCase2()
        {
            Document document = new Mono.TextEditor.Document();

            document.Text =
                @"-[1
+[2
3
]4
5
+[6
+[7
+[8
9
]10
]11
]12
]13
14
+[15
16
]17
18";
            document.UpdateFoldSegments(GetFoldSegments(document), false);
            Assert.AreEqual(6, document.VisualToLogicalLine(4));
            Assert.AreEqual(14, document.VisualToLogicalLine(6));
            Assert.AreEqual(15, document.VisualToLogicalLine(7));
        }
Example #10
0
        public void TestVisualToLogicalLineStartLine()
        {
            Document document = new Mono.TextEditor.Document();

            document.Text =
                @"-[1
-[2
3
]4
5
-[6
+[7
-[8
9
]10
]11
]12
]13
14
-[15
16
]17
18";
            document.UpdateFoldSegments(GetFoldSegments(document), false);
            Assert.AreEqual(7, document.VisualToLogicalLine(7));
        }
        public void TestVisualToLogicalLine()
        {
            Document document = new Mono.TextEditor.Document();

            document.Text =
                @"-[0
+[1
2
]3
4
+[5
+[6
+[7
8
]9
]10
]11
]12
13
+[14
15
]16
17";
            document.UpdateFoldSegments(GetFoldSegments(document));
            do
            {
                Gtk.Application.RunIteration();
            } while (!document.HasFoldSegments);
            Assert.AreEqual(4, document.LogicalToVisualLine(12));
            Assert.AreEqual(6, document.LogicalToVisualLine(16));
            Assert.AreEqual(7, document.LogicalToVisualLine(17));
        }
Example #12
0
		public void TestBug682466 ()
		{
			Document document = new Mono.TextEditor.Document ();
			document.Text = 
@"0
1
2
+[3
4
5
6]
7
8
9
10";
			var segments = GetFoldSegments (document);
			document.UpdateFoldSegments (segments, false);
			Assert.AreEqual (true, document.FoldSegments.FirstOrDefault ().IsFolded);
			segments = GetFoldSegments (document);
			segments[0].IsFolded = false;
			document.UpdateFoldSegments (segments, false);
			Assert.AreEqual (5, document.LogicalToVisualLine (8));
		}
Example #13
0
		public void TestUpdateFoldSegmentBug ()
		{
			Document document = new Mono.TextEditor.Document ();
			document.Text = 
@"-[0
1
+[2
3
4
5
6
7
8
9
10]
11
]12
13
+[14
15
16
17
18
19
20
21
22]
23
24
25
26";
			var segments = GetFoldSegments (document);
			document.UpdateFoldSegments (segments, false);
			Assert.AreEqual (25, document.VisualToLogicalLine (9));
			segments.RemoveAt (1);
			
			document.UpdateFoldSegments (segments, false);
			
			Assert.AreEqual (17, document.LogicalToVisualLine (25));
			segments.RemoveAt (1);
			document.UpdateFoldSegments (segments, false);
			Assert.AreEqual (25, document.LogicalToVisualLine (25));
		}
Example #14
0
		public void TestGetStartFoldingsGetStartFoldings ()
		{
			Document document = new Mono.TextEditor.Document ();
			document.Text = 
@"+[1
2
3
+[4
5
+[6
7]
8]
+[9
10
11]
12]
+[13
14]
15
16";
			var segments = GetFoldSegments (document);
			document.UpdateFoldSegments (segments, false);
			document.UpdateFoldSegments (segments, false);
			document.UpdateFoldSegments (segments, false);
			
			Assert.AreEqual (1, document.GetStartFoldings (1).Count ());
			Assert.AreEqual (1, document.GetStartFoldings (4).Count ());
			Assert.AreEqual (1, document.GetStartFoldings (6).Count ());
			Assert.AreEqual (1, document.GetStartFoldings (9).Count ());
			Assert.AreEqual (1, document.GetStartFoldings (13).Count ());
		}
Example #15
0
		public void TestIsFoldedUnsetFolded ()
		{
			Document document = new Mono.TextEditor.Document ();
			document.Text = 
@"-[1
2
3
+[4
5
+[6
7]
8]
-[9
10
11]
12]
-[13
14]
15
16";
			var segments = GetFoldSegments (document);
			document.UpdateFoldSegments (segments, false);
			Assert.AreEqual (11, document.LogicalToVisualLine (15));
			document.GetStartFoldings (6).First ().IsFolded = false;
			document.GetStartFoldings (4).First ().IsFolded = false;
			Assert.AreEqual (15, document.LogicalToVisualLine (15));
		}
Example #16
0
		public void TestUpdateFoldSegmentBug2 ()
		{
			Document document = new Mono.TextEditor.Document ();
			document.Text = 
@"-[1
2
+[3
4]
5
+[6
7]
8
9
10
11
12
13
14]
15
16";
			var segments = GetFoldSegments (document);
			document.UpdateFoldSegments (segments, false);
			Assert.AreEqual (10, document.VisualToLogicalLine (8));
			Assert.AreEqual (3, document.FoldSegments.Count ());
			int start = document.GetLine (2).Offset;
			int end = document.GetLine (8).Offset;
			((IBuffer)document).Remove (start, end - start);
			Assert.AreEqual (1, document.FoldSegments.Count ());
			Assert.AreEqual (10, document.LogicalToVisualLine (10));
		}
Example #17
0
		public void TestUpdateFoldSegmentBug2 ()
		{
			Document document = new Mono.TextEditor.Document ();
			document.Text = 
@"-[0
1
+[2
3]
4
+[5
6]
7
8
9
10
11
12
13]
14
15";
			var segments = GetFoldSegments (document);
			document.UpdateFoldSegments (segments, false);
			Assert.AreEqual (10, document.VisualToLogicalLine (8));
			int start = document.GetLine (2).Offset;
			int end = document.GetLine (8).Offset;
			((IBuffer)document).Remove (start, end - start);
			Assert.AreEqual (10, document.LogicalToVisualLine (10));
		}
Example #18
0
		public void TestVisualToLogicalLine ()
		{
			Document document = new Mono.TextEditor.Document ();
			document.Text = 
@"-[0
+[1
2
]3
4
+[5
+[6
+[7
8
]9
]10
]11
]12
13
+[14
15
]16
17";
			document.UpdateFoldSegments (GetFoldSegments (document));
			do {
				Gtk.Application.RunIteration ();
			} while (!document.HasFoldSegments);
			Assert.AreEqual (4, document.LogicalToVisualLine (12));
			Assert.AreEqual (6, document.LogicalToVisualLine (16));
			Assert.AreEqual (7, document.LogicalToVisualLine (17));
		}
Example #19
0
		public void TestLogicalToVisualLineStartLine ()
		{
			Document document = new Mono.TextEditor.Document ();
			document.Text = 
@"-[1
-[2
3
]4
5
-[6
+[7
-[8
9
]10
]11
]12
]13
14
-[15
16
]17
18";
			document.UpdateFoldSegments (GetFoldSegments (document), false);
			Assert.AreEqual (7, document.LogicalToVisualLine (7));
		}
Example #20
0
		public void TestLogicalToVisualLine ()
		{
			Document document = new Mono.TextEditor.Document ();
			document.Text = 
@"-[1
+[2
3
]4
5
+[6
+[7
+[8
9
]10
]11
]12
]13
14
+[15
16
]17
18";
			document.UpdateFoldSegments (GetFoldSegments (document), false);
			Assert.AreEqual (4, document.LogicalToVisualLine (12));
			Assert.AreEqual (6, document.LogicalToVisualLine (16));
			Assert.AreEqual (7, document.LogicalToVisualLine (17));
		}
Example #21
0
		public void TestVisualToLogicalLine ()
		{
			Document document = new Mono.TextEditor.Document ();
			document.Text = 
@"-[0
+[1
2
]3
4
+[5
+[6
+[7
8
]9
]10
]11
]12
13
+[14
15
]16
17";
			document.UpdateFoldSegments (GetFoldSegments (document), false);
			Assert.AreEqual (4, document.LogicalToVisualLine (12));
			Assert.AreEqual (6, document.LogicalToVisualLine (16));
			Assert.AreEqual (7, document.LogicalToVisualLine (17));
		}
Example #22
0
		public void TestVisualToLogicalLineCase2 ()
		{
			Document document = new Mono.TextEditor.Document ();
			document.Text = 
@"-[1
+[2
3
]4
5
+[6
+[7
+[8
9
]10
]11
]12
]13
14
+[15
16
]17
18";
			document.UpdateFoldSegments (GetFoldSegments (document), false);
			Assert.AreEqual (6, document.VisualToLogicalLine (4));
			Assert.AreEqual (14, document.VisualToLogicalLine (6));
			Assert.AreEqual (15, document.VisualToLogicalLine (7));
		}