public void TextNotChangedWhenGreaterThanCharTypedAndChildEndElementAlreadyExists() { string text = "<root>\r\n" + "\t<child></child>\r\n" + "</root>\r\n"; document.Text = text; // Just typed the '>' character of the <child> element textEditor.Caret.Offset = 16; formattingStrategy.FormatLine(textEditor, '>'); Assert.AreEqual(text, document.Text); }
void TextArea_TextEntered(object sender, TextCompositionEventArgs e) { if (e.Text.Length > 0 && !e.Handled) { if (e.Text.Length == 1) { var c = e.Text[0]; if (c == '\r') { c = '\n'; } _formattingStrategy.FormatLine(this, c); CodeCompletion?.HandleKeyPressed(this, c); } } }
public void Init() { formattingStrategy = new XmlFormattingStrategy(); options = new MockTextEditorOptions(); textEditor = new MockTextEditor(); textEditor.Options = options; textDocument = new TextDocument(); document = textDocument; textEditor.SetDocument(document); document.Text = "<root>\r\n" + "\t<child>\r\n" + "</root>\r\n"; // Just typed the '>' character of the <child> element textEditor.Caret.Offset = 16; formattingStrategy.FormatLine(textEditor, '>'); }