Skip to content

Commit 10d9bf1

Browse files
Norman Rzepkamarijnh
authored andcommitted
continuelist: hitting enter twice cancels the list
1 parent 0caeb00 commit 10d9bf1

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

addon/edit/continuelist.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"use strict";
1313

1414
var listRE = /^(\s*)([*+-]|(\d+)\.)(\s+)/,
15+
emptyListRE = /^(\s*)([*+-]|(\d+)\.)(\s*)$/,
1516
unorderedBullets = "*+-";
1617

1718
CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
@@ -25,12 +26,22 @@
2526
cm.execCommand("newlineAndIndent");
2627
return;
2728
}
28-
var indent = match[1], after = match[4];
29-
var bullet = unorderedBullets.indexOf(match[2]) >= 0
30-
? match[2]
31-
: (parseInt(match[3], 10) + 1) + ".";
29+
if (cm.getLine(pos.line).match(emptyListRE)) {
30+
cm.replaceRange("", {
31+
line: pos.line, ch: 0
32+
}, {
33+
line: pos.line, ch: pos.ch + 1
34+
});
35+
replacements[i] = "\n";
3236

33-
replacements[i] = "\n" + indent + bullet + after;
37+
} else {
38+
var indent = match[1], after = match[4];
39+
var bullet = unorderedBullets.indexOf(match[2]) >= 0
40+
? match[2]
41+
: (parseInt(match[3], 10) + 1) + ".";
42+
43+
replacements[i] = "\n" + indent + bullet + after;
44+
}
3445
}
3546

3647
cm.replaceSelections(replacements);

0 commit comments

Comments
 (0)