public void TestBackspaceUTF32() { var data = Create(@"12🚀$34"); DeleteActions.Backspace(data); Check(data, @"12$34"); }
static async void RemoveCharBeforCaret(TextEditorData data) { if (!data.IsSomethingSelected && MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.AutoInsertMatchingBracket) { if (data.Caret.Offset > 0) { char ch = data.Document.GetCharAt(data.Caret.Offset - 1); DeleteActions.Backspace(data); if (data.Caret.Offset > 0) { var stack = await data.Document.SyntaxMode.GetScopeStackAsync(data.Caret.Offset - 1, CancellationToken.None); if (stack.Any(s => s.Contains("string") || s.Contains("comment"))) { return; } } int idx = open.IndexOf(ch); if (idx >= 0) { int nextCharOffset = GetNextNonWsCharOffset(data, data.Caret.Offset); if (nextCharOffset >= 0 && closing[idx] == data.Document.GetCharAt(nextCharOffset)) { data.Remove(data.Caret.Offset, nextCharOffset - data.Caret.Offset + 1); } } return; } } DeleteActions.Backspace(data); }
public void TestBackspaceCase1() { var data = Create(@"$1234567890"); DeleteActions.Backspace(data); Check(data, @"$1234567890"); }
static void RemoveCharBeforCaret(TextEditorData data) { if (((ISourceEditorOptions)data.Options).AutoInsertMatchingBracket) { if (data.Caret.Offset > 0) { char ch = data.Document.GetCharAt(data.Caret.Offset - 1); int idx = open.IndexOf(ch); if (idx >= 0) { int nextCharOffset = GetNextNonWsCharOffset(data, data.Caret.Offset); if (nextCharOffset >= 0 && closing[idx] == data.Document.GetCharAt(nextCharOffset)) { bool updateToEnd = data.Document.OffsetToLineNumber(nextCharOffset) != data.Caret.Line; data.Remove(data.Caret.Offset, nextCharOffset - data.Caret.Offset + 1); if (updateToEnd) { data.Document.CommitLineToEndUpdate(data.Caret.Line); } } } } } DeleteActions.Backspace(data); }
static void RemoveCharBeforCaret(TextEditorData data) { if (!data.IsSomethingSelected && MonoDevelop.Ide.Editor.DefaultSourceEditorOptions.Instance.AutoInsertMatchingBracket) { if (data.Caret.Offset > 0) { var line = data.GetLine(data.Caret.Line); var stack = line.StartSpan.Clone(); if (stack.Any(s => s.Color == "string.other")) { DeleteActions.Backspace(data); return; } stack = line.StartSpan.Clone(); if (stack.Any(s => s.Color == "string.other")) { DeleteActions.Backspace(data); return; } char ch = data.Document.GetCharAt(data.Caret.Offset - 1); int idx = open.IndexOf(ch); if (idx >= 0) { int nextCharOffset = GetNextNonWsCharOffset(data, data.Caret.Offset); if (nextCharOffset >= 0 && closing[idx] == data.Document.GetCharAt(nextCharOffset)) { data.Remove(data.Caret.Offset, nextCharOffset - data.Caret.Offset + 1); } } } } DeleteActions.Backspace(data); }
public void TestBackspaceCase1() { TextEditorData data = CaretMoveActionTests.Create(@"$1234567890"); DeleteActions.Backspace(data); Assert.AreEqual(new DocumentLocation(0, 0), data.Caret.Location); Assert.AreEqual("1234567890", data.Document.Text); }
public void TestRemoveExistingIndentWithBackspace() { var data = CreateData("\n\t\t\t\n\n"); data.Caret.Location = new DocumentLocation(2, 4); DeleteActions.Backspace(data); Assert.AreEqual(3, data.Caret.Column); Assert.AreEqual("\n\n\n", data.Document.Text); }
public void TestRemoveLastTabInLine() { var data = CreateData("\n\t\n\n"); data.Caret.Location = new DocumentLocation(2, 2); DeleteActions.Backspace(data); Assert.AreEqual("\n\n\n", data.Document.Text); Assert.AreEqual(1, data.Caret.Offset); }
public void TestBug5956() { var data = CreateData("\t\tfoo\n\n\t\tbar"); data.Caret.Location = new DocumentLocation(3, 1); DeleteActions.Backspace(data); Assert.AreEqual(new DocumentLocation(2, 3), data.Caret.Location); Assert.AreEqual("\t\tfoo\n\t\t\t\tbar", data.Document.Text); }
public void TestSmartBackspaceBehaviorCase2() { var data = CreateData("\n\t\tTest\n\t\t"); data.Caret.Location = new DocumentLocation(3, 3); DeleteActions.Backspace(data); Assert.AreEqual(new DocumentLocation(2, 7), data.Caret.Location); Assert.AreEqual("\n\t\tTest", data.Document.Text); }
public void TestSmartExistingLineBackspace() { var data = CreateData("\n\t\t\n\t\tTest"); data.Caret.Location = new DocumentLocation(3, 3); DeleteActions.Backspace(data); Assert.AreEqual(new DocumentLocation(2, 3), data.Caret.Location); Assert.AreEqual("\n\t\tTest", data.Document.Text); }
public void TestBackspaceRightBehavior() { var data = CreateData("test\n\n\n"); data.Caret.Location = new DocumentLocation(2, data.GetVirtualIndentationColumn(2, 1)); DeleteActions.Backspace(data); Assert.AreEqual(new DocumentLocation(1, 5), data.Caret.Location); Assert.AreEqual("test\n\n", data.Document.Text); }
public void TestBug5402() { var data = CreateData("\t"); data.IndentationTracker = new SmartIndentModeTests.TestIndentTracker("\t"); data.Caret.Location = new DocumentLocation(1, 2); DeleteActions.Backspace(data); Assert.AreEqual("", data.Document.Text); Assert.AreEqual(0, data.Caret.Offset); }
public void TestBug5402() { var data = new TextEditorData(); data.IndentationTracker = new SmartIndentModeTests.TestIndentTracker("\t"); data.Document.Text = "\t"; data.Caret.Location = new DocumentLocation(1, 2); DeleteActions.Backspace(data); Assert.AreEqual("", data.Document.Text); Assert.AreEqual(new DocumentLocation(1, 1), data.Caret.Location); }
public void TestBug15476() { var data = CreateData("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n\t\t\r\n\r\n"); data.Options.DefaultEolMarker = "\r\n"; data.IndentationTracker = new DefaultIndentationTracker(data.Document); data.Caret.Location = new DocumentLocation(4, 3); DeleteActions.Backspace(data); Assert.AreEqual(new DocumentLocation(3, 3), data.Caret.Location); }
public void TestBackspaceSelectionBehavior() { var data = CreateData("\n\t\ttest\n\n"); data.Caret.Location = new DocumentLocation(2, 3); SelectionActions.MoveUp(data); Assert.AreEqual(new DocumentLocation(1, 3), data.Caret.Location); Assert.IsTrue(data.IsSomethingSelected); DeleteActions.Backspace(data); Assert.AreEqual(new DocumentLocation(1, 3), data.Caret.Location); Assert.AreEqual("\t\ttest\n\n", data.Document.Text); }
public void TestBug613770() { 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 = DocumentLocation.MinColumn + 4; DeleteActions.Backspace(data); Assert.AreEqual("\n\n\n", data.Document.Text); }
public void TestEmptyLineSmartBackspace() { var data = CreateData("\n\n\n\n"); data.IndentationTracker = new SmartIndentModeTests.TestIndentTracker("\t"); data.Caret.Location = new DocumentLocation(3, 2); DeleteActions.Backspace(data); Assert.AreEqual(new DocumentLocation(2, 2), data.Caret.Location); Assert.AreEqual("\n\n\n", data.Document.Text); DeleteActions.Backspace(data); Assert.AreEqual(new DocumentLocation(1, 2), data.Caret.Location); Assert.AreEqual("\n\n", data.Document.Text); }
public void TestAutoRemoveIndent() { var data = CreateData("\n\t\t\n\n"); data.Caret.Location = new DocumentLocation(2, 3); data.InsertAtCaret(" "); Assert.AreEqual("\n\t\t \n\n", data.Document.Text); DeleteActions.Backspace(data); Assert.AreEqual("\n\n\n", data.Document.Text); Assert.AreEqual(data.GetVirtualIndentationColumn(2, 1), data.Caret.Column); }
public void TestVSTS624076() { var data = Create(" \n$"); // set indent tracker without smart backspace functionality. data.IndentationTracker = new SmartIndentModeTests.TestIndentTracker(" ", IndentationTrackerFeatures.None); data.Options.IndentStyle = IndentStyle.Virtual; data.Caret.Location = new DocumentLocation(2, 5); DeleteActions.Backspace(data); // behavior : virtual indent is converted into real indent and 1 space of the real indent is deleted Check(data, " \n $"); }
public void TestLinkRemoval() { var editor = CreateEditorWithLinks(@"[0foo] [0foo] [0foo]", out var links); editor.Options.IndentStyle = IndentStyle.Auto; var oldLocation = editor.Caret.Location; var tle = new TextLinkEditMode(editor, 0, links); tle.StartMode(); DeleteActions.Backspace(editor.GetTextEditorData()); tle.ExitTextLinkMode(); Assert.AreEqual(" ", editor.Text); }
public void TestBackspace() { var editor = new MonoTextEditor(); editor.GetTextEditorData().Document.SyntaxMode = new TestSyntaxMode(); editor.Text = @"1 2 3 4 5"; editor.Caret.Location = new DocumentLocation(2, 1); editor.InsertAtCaret("a"); Assert.IsTrue(editor.TextViewMargin.SpanUpdater.HasUpdatedMultilineSpan); DeleteActions.Backspace(editor.GetTextEditorData()); Assert.IsTrue(editor.TextViewMargin.SpanUpdater.HasUpdatedMultilineSpan); }
protected override void Run() { // hack for last line, it doesn't actually cut the line though if (Editor.Caret.Offset == Editor.Text.Length) { var line = Editor.GetLine(Editor.Caret.Line); if (line.Offset == line.EndOffset) { DeleteActions.Backspace(Editor); return; } } Motion.SetSelectLines(Editor, Editor.Caret.Line, Editor.Caret.Line + Count + (Count > 0 ? -1 : 0)); ClipboardActions.Cut(Editor); Motion.LineStart(Editor); }
public void TestBackspace() { var data = Create( @"1234567890 1234<-567890 1234567890 1234567890 1234->$567890 1234567890"); data.MainSelection.SelectionMode = SelectionMode.Block; DeleteActions.Backspace(data); Check(data, @"1234567890 123<-567890 123567890 123567890 123->$567890 1234567890"); }
public void TestBackspaceWithTabs() { var data = Create( @"1234567890 " + '\t' + @"1234<-567890 ....1234567890 ....1234567890 ....1234->$567890 1234567890"); data.MainSelection = data.MainSelection.WithSelectionMode(SelectionMode.Block); DeleteActions.Backspace(data); Check(data, @"1234567890 " + '\t' + @"123<-567890 ....123567890 ....123567890 ....123->$567890 1234567890"); }
static void RemoveCharBeforCaret(TextEditorData data) { if (((ISourceEditorOptions)data.Options).AutoInsertMatchingBracket) { if (data.Caret.Offset > 0) { var line = data.GetLine(data.Caret.Line); var stack = line.StartSpan.Clone(); Mono.TextEditor.Highlighting.SyntaxModeService.ScanSpans(data.Document, data.Document.SyntaxMode, data.Document.SyntaxMode, stack, line.Offset, data.Caret.Offset - 1); if (stack.Any(s => s.Color == "string.other")) { DeleteActions.Backspace(data); return; } stack = line.StartSpan.Clone(); Mono.TextEditor.Highlighting.SyntaxModeService.ScanSpans(data.Document, data.Document.SyntaxMode, data.Document.SyntaxMode, stack, line.Offset, data.Caret.Offset); if (stack.Any(s => s.Color == "string.other")) { DeleteActions.Backspace(data); return; } char ch = data.Document.GetCharAt(data.Caret.Offset - 1); int idx = open.IndexOf(ch); if (idx >= 0) { int nextCharOffset = GetNextNonWsCharOffset(data, data.Caret.Offset); if (nextCharOffset >= 0 && closing[idx] == data.Document.GetCharAt(nextCharOffset)) { bool updateToEnd = data.Document.OffsetToLineNumber(nextCharOffset) != data.Caret.Line; data.Remove(data.Caret.Offset, nextCharOffset - data.Caret.Offset + 1); if (updateToEnd) { data.Document.CommitLineToEndUpdate(data.Caret.Line); } } } } } DeleteActions.Backspace(data); }
public void TestVSTS627497() { var editor = CreateEditorWithLinks(@"[0class] Test { void TestMethod () { $ } }", out var links); var oldLocation = editor.Caret.Location; var tle = new TextLinkEditMode(editor, 0, links); tle.StartMode(); DeleteActions.Backspace(editor.GetTextEditorData()); editor.InsertAtCaret("struct"); tle.ExitTextLinkMode(); Assert.AreEqual(oldLocation, editor.Caret.Location); }