public static void NewLineBelow(TextEditorData data) { DocumentLine currentLine = data.Document.GetLine(data.Caret.Line); data.Caret.Offset = currentLine.Offset + currentLine.Length; MiscActions.InsertNewLine(data); }
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 {}"); }
public void TestEnterSelectionBehavior() { var data = Create("\tfirst\n<-\tsecond\n->$\tthird"); MiscActions.InsertNewLine(data); CheckOutput(data, "\tfirst\n\t$third"); }
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$"); }
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>"); }
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)); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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; }
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); }
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); }
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); }
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); }