Skip to content

Commit 81a0505

Browse files
committed
Merge pull request #157 from SamLau95/patch-1
Stop leading space after entering Markdown
2 parents 049e842 + 03336c2 commit 81a0505

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/markdown.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,17 @@
3434
var code = e.keyCode || e.which;
3535

3636
// when `space` is pressed
37-
if(code === 32) {
38-
var cmd = this.stack.join('');
39-
this.stack.length = 0;
40-
return this.valid(cmd);
37+
if (code === 32) {
38+
var markdownSyntax = this.stack.join('');
39+
// reset stack
40+
this.stack = [];
41+
42+
var cmd = this.valid(markdownSyntax);
43+
if (cmd) {
44+
// prevents leading space after executing command
45+
e.preventDefault();
46+
return cmd;
47+
}
4148
}
4249

4350
// make cmd

0 commit comments

Comments
 (0)