Exemplo n.º 1
0
        public static void NewLineBelow(TextEditorData data)
        {
            DocumentLine currentLine = data.Document.GetLine(data.Caret.Line);

            data.Caret.Offset = currentLine.Offset + currentLine.Length;
            MiscActions.InsertNewLine(data);
        }
Exemplo n.º 2
0
        public void TestBug15335()
        {
            var data = Create("namespace Foo\n{\n\tpublic class Bar\n\t{\n\t\tvoid Test()\r\n\t\t{\r\n\t\t\t/* foo$\n\t\t}\n\t}\n}\n");

            MiscActions.InsertNewLine(data);

            CheckOutput(data, "namespace Foo\n{\n\tpublic class Bar\n\t{\n\t\tvoid Test()\r\n\t\t{\r\n\t\t\t/* foo\n\t\t\t * $\n\t\t}\n\t}\n}\n");
        }
        public void TestMultiLineCommentContinuation()
        {
            var data = Create("\t\t/*$" + eolMarker + "\t\tclass Foo {}");

            MiscActions.InsertNewLine(data);

            CheckOutput(data, "\t\t/*" + eolMarker + "\t\t * $" + eolMarker + "\t\tclass Foo {}");
        }
Exemplo n.º 4
0
        public void TestEnterSelectionBehavior()
        {
            var data = Create("\tfirst\n<-\tsecond\n->$\tthird");

            MiscActions.InsertNewLine(data);

            CheckOutput(data, "\tfirst\n\t$third");
        }
Exemplo n.º 5
0
        public void TestIndentWithSpaces()
        {
            var data = CreateDataWithSpaces("\n        \n\n");

            data.Caret.Location = new DocumentLocation(2, 9);
            MiscActions.InsertNewLine(data);
            Assert.AreEqual("\n\n\n\n", data.Document.Text);
        }
        public void TestStringContination()
        {
            var data = Create("\t\t\"Hello$ World\"");

            MiscActions.InsertNewLine(data);

            CheckOutput(data, "\t\t\"Hello\" +" + eolMarker + "\t\t\"$World\"");
        }
        public void TestBug3214()
        {
            var data = Create("\"Hello\n\t$");

            MiscActions.InsertNewLine(data);

            CheckOutput(data, "\"Hello\n\t" + eolMarker + "\t$");
        }
Exemplo n.º 8
0
        public void TestBug11966()
        {
            var data = Create("///<summary>This is a long comment $ </summary>");

            MiscActions.InsertNewLine(data);

            CheckOutput(data, @"///<summary>This is a long comment 
/// $ </summary>");
        }
Exemplo n.º 9
0
		public void TestBug4839 ()
		{
			var editor = Create ("1\n2\n3\n4\n5\n6\n7");
			editor.Caret.Offset = editor.Text.Length;
			var heightTree = new HeightTree (editor);
			heightTree.Rebuild ();
			MiscActions.InsertNewLine (editor);
			Assert.AreEqual ((editor.LineCount - 1) * editor.LineHeight, heightTree.LineNumberToY (editor.LineCount));
		}
Exemplo n.º 10
0
        public void TestReturnOnNonEmptyLine()
        {
            var data = CreateData("\n\t\tFoo\t\tBar\n\n");

            data.Caret.Location = new DocumentLocation(2, 3);
            MiscActions.InsertNewLine(data);
            Assert.AreEqual(3, data.Caret.Column);
            Assert.AreEqual("\n\n\t\tFoo\t\tBar\n\n", data.Document.Text);
        }
Exemplo n.º 11
0
        public void TestAutoRemoveExistingIndentOnReturn()
        {
            var data = CreateData("\n\t\t\n\n");

            data.Caret.Location = new DocumentLocation(2, 3);
            MiscActions.InsertNewLine(data);
            MiscActions.InsertNewLine(data);
            Assert.AreEqual(3, data.Caret.Column);
            Assert.AreEqual("\n\n\n\n\n", data.Document.Text);
        }
Exemplo n.º 12
0
        public void TestVSTS801783()
        {
            TextEditorData data = new Mono.TextEditor.TextEditorData();

            data.IndentationTracker = new SmartIndentModeTests.TestIndentTracker("   ");
            data.Document.Text      = "HelloWorld!";
            data.Caret.Location     = new DocumentLocation(1, "Hello".Length);
            MiscActions.InsertNewLine(data);
            Assert.AreEqual(4, data.Caret.Column);
        }
Exemplo n.º 13
0
        public void TestIndentNewLine()
        {
            var data = CreateData("\n\n\n");

            data.Caret.Offset = data.Document.GetLine(2).Offset;

            MiscActions.InsertNewLine(data);

            Assert.AreEqual("\n\n\t\t\n\n", data.Document.Text);
            Assert.AreEqual(data.Document.GetLine(3).Offset + 2, data.Caret.Offset);
        }
Exemplo n.º 14
0
        public void TestIndentNewLine()
        {
            var data = CreateData("\n\n\n");

            data.Caret.Offset = data.Document.GetLine(2).Offset;

            MiscActions.InsertNewLine(data);

            Assert.AreEqual("\n\n\n\n", data.Document.Text);
            Assert.AreEqual(data.GetVirtualIndentationColumn(2, 1), data.Caret.Column);
        }
Exemplo n.º 15
0
        public void TestBug53878()
        {
            var data = CreateData("    FooBar\n    Foo {}");

            data.Caret.Offset        = data.Document.GetLine(2).EndOffset - 1;
            data.Options.IndentStyle = IndentStyle.Auto;
            MiscActions.InsertNewLine(data);

            Assert.AreEqual("    FooBar\n    Foo {\n    }", data.Document.Text);
            Assert.AreEqual(data.Document.GetLine(3).EndOffset - 1, data.Caret.Offset);
        }
Exemplo n.º 16
0
        public void TestStringContination()
        {
            var data = Create("\t\t\"Hello$World\"");

            MiscActions.InsertNewLine(data);

            var engine = new CSharpTextEditorIndentation {
                wasInStringLiteral = true
            };

            CheckOutput(data, "\t\t\"Hello\" +" + eolMarker + "\t\t\"$World\"", engine);
        }
Exemplo n.º 17
0
        public void TestBug17896()
        {
            var data = Create("\t\t\"This is a long test string.$        It contains spaces.\"");

            MiscActions.InsertNewLine(data);

            var engine = new CSharpTextEditorIndentation {
                wasInStringLiteral = true
            };

            CheckOutput(data, "\t\t\"This is a long test string.\" +" + eolMarker + "\t\t\"$        It contains spaces.\"", engine);
        }
Exemplo n.º 18
0
        public void TestInsertNewLine()
        {
            TextEditorData data = new Mono.TextEditor.TextEditorData();

            data.Document.Text  = "Hello World!";
            data.Caret.Location = new DocumentLocation(1, "Hello".Length + 1);
            MiscActions.InsertNewLine(data);
            Assert.AreEqual(2, data.Document.LineCount);
            Assert.AreEqual(2, data.Caret.Line);
            Assert.AreEqual(1, data.Caret.Column);
            Assert.AreEqual("Hello" + Environment.NewLine + " World!", data.Document.Text);
        }
        public void TestXmlDocumentContinuationCase2()
        {
            var data = Create("\t\t///" + eolMarker +
                              "\t\t/// Hel$lo" + eolMarker +
                              "\t\tclass Foo {}");

            MiscActions.InsertNewLine(data);

            CheckOutput(data, "\t\t///" + eolMarker +
                        "\t\t/// Hel" + eolMarker +
                        "\t\t/// $lo" + eolMarker +
                        "\t\tclass Foo {}");
        }
        public void TestReturnKeyBehavior()
        {
            TextEditorData data = new Mono.TextEditor.TextEditorData();

            data.Document.Text = "\n\n\n";
            data.Caret.Offset  = 1;            // 2nd.Line
            data.Caret.AllowCaretBehindLineEnd = true;
            data.Caret.Column = 4;
            data.Options.RemoveTrailingWhitespaces = false;
            MiscActions.InsertNewLine(data);

            Assert.AreEqual("\n    \n    \n\n", data.Document.Text);
        }
Exemplo n.º 21
0
        public void TestReturnKeyBehavior()
        {
            TextEditorData data = new Mono.TextEditor.TextEditorData();

            data.Options.IndentStyle           = IndentStyle.Auto;
            data.Document.Text                 = "\n\n\n";
            data.Caret.Offset                  = 1; // 2nd.Line
            data.Caret.AllowCaretBehindLineEnd = true;
            data.Caret.Column                  = DocumentLocation.MinColumn + 4;
            MiscActions.InsertNewLine(data);

            Assert.AreEqual("\n    \n    \n\n", data.Document.Text);
        }
Exemplo n.º 22
0
 protected override void Run()
 {
     if (Editor.Caret.Line == DocumentLocation.MinLine)
     {
         Editor.Caret.Column = 1;
         MiscActions.InsertNewLine(Editor);
         CaretMoveActions.Up(Editor);
     }
     else
     {
         CaretMoveActions.Up(Editor);
         MiscActions.InsertNewLineAtEnd(Editor);
     }
     RequestedMode = Mode.Insert;
 }
Exemplo n.º 23
0
        public static void NewLineAbove(TextEditorData data)
        {
            if (data.Caret.Line == 0)
            {
                data.Caret.Offset = 0;
                MiscActions.InsertNewLine(data);
                data.Caret.Offset = 0;
                return;
            }

            LineSegment currentLine = data.Document.GetLine(data.Caret.Line - 1);

            data.Caret.Offset = currentLine.Offset + currentLine.EditableLength;
            MiscActions.InsertNewLine(data);
        }
Exemplo n.º 24
0
        public static void NewLineAbove(TextEditorData data)
        {
            if (data.Caret.Line == DocumentLocation.MinLine)
            {
                data.Caret.Offset = 0;
                MiscActions.InsertNewLine(data);
                data.Caret.Offset = 0;
                return;
            }

            DocumentLine currentLine = data.Document.GetLine(data.Caret.Line - 1);

            data.Caret.Offset = currentLine.Offset + currentLine.Length;
            MiscActions.InsertNewLine(data);
        }
Exemplo n.º 25
0
        public void TestBug25602()
        {
            var data = Create(@"
using System;

#if DEBUG
namespace TestBadFormating
#endif
{
	// Some test code here bla baaa...$
	class MainClass
	{
");

            MiscActions.InsertNewLine(data);
            Assert.AreEqual(2, data.Caret.Column);
        }
Exemplo n.º 26
0
        public void TestBug16174_VirtualIndent()
        {
            TestViewContent content;

            var ext = Setup("namespace Foo\n{\n\tpublic class Bar\n\t{\n$\t\tvoid Test()\n\t\t{\n\t\t}\n\t}\n}\n", out content);

            ext.document.Editor.Options.IndentStyle = IndentStyle.Virtual;
            MiscActions.InsertNewLine(content.Data);
            ext.KeyPress(Gdk.Key.Return, '\n', Gdk.ModifierType.None);

            var newText = content.Text;

            var expected = "namespace Foo\n{\n\tpublic class Bar\n\t{\n\n\t\tvoid Test()\n\t\t{\n\t\t}\n\t}\n}\n";

            if (newText != expected)
            {
                Console.WriteLine(newText);
            }
            Assert.AreEqual(expected, newText);
        }
        public void TestCorrectReindentNextLine()
        {
            TestViewContent content;
            var             ext = Setup(@"
class Foo
{
	void Bar ()
	{
		try {
		} catch (Exception e) {$}
	}
}
", out content);

            ext.ReindentOnTab();
            MiscActions.InsertNewLine(content.Data);
            ext.KeyPress((Gdk.Key) '\n', '\n', Gdk.ModifierType.None);

            var newText = content.Text;

            var expected = @"
class Foo
{
	void Bar ()
	{
		try {
		} catch (Exception e) {
		}
	}
}
";

            if (newText != expected)
            {
                Console.WriteLine(newText);
            }
            Assert.AreEqual(expected, newText);
        }