Code52 / DownmarkerWPF

MarkPad - a visual Markdown editor (inspired by the Downmarker project)
http://code52.org/DownmarkerWPF/
Microsoft Public License
1.4k stars 458 forks source link

#266 - Added automatic paired characters #420

Closed scottgulliver closed 10 years ago

scottgulliver commented 10 years ago

Implemented paired characters, as described in issue #266. For the characters (), [], {}, '', "", <>:

  1. When inserting the opening char, the closing char gets added automatically.
  2. Deletion of the closing brace is automatic when backspacing the opening char, and the close is immediately to the right.
  3. Overtyping of the closing brace is also implemented.
  4. Highlighting of matching pairs has also been added.
JakeGinnivan commented 10 years ago

That is awesome, just tried it out. Also FYI i am going to write some UI automation tests (which for some reason are super slow for me at the moment... will look into that.)

    public class PairedCharactersFacts : MarkpadUiTest
    {
        [Fact]
        public void InsertsPairedCharacters()
        {
            var document = MainWindow.NewDocument();
            var editor = document.Editor();

            editor.TypeText("\"");
            editor.PressKey(KeyboardInput.SpecialKeys.RIGHT);
            editor.TypeText("'");
            editor.PressKey(KeyboardInput.SpecialKeys.RIGHT);
            editor.TypeText("(");
            editor.PressKey(KeyboardInput.SpecialKeys.RIGHT);
            editor.TypeText("{");
            editor.PressKey(KeyboardInput.SpecialKeys.RIGHT);
            editor.TypeText("[");
            editor.PressKey(KeyboardInput.SpecialKeys.RIGHT);
            editor.TypeText("<");
            editor.PressKey(KeyboardInput.SpecialKeys.RIGHT);

            Assert.Equal("\"\"''(){}[]<>", editor.MarkdownText);
        }

        [Fact]
        public void CanOverwritePairedCharacter()
        {
            var document = MainWindow.NewDocument();
            var editor = document.Editor();

            editor.TypeText("[Link test](http://google.com)");

            Assert.Equal("[Link test](http://google.com)", editor.MarkdownText);
        }
    }