File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change 1212 "use strict" ;
1313
1414 var listRE = / ^ ( \s * ) ( [ * + - ] | ( \d + ) \. ) ( \s + ) / ,
15+ emptyListRE = / ^ ( \s * ) ( [ * + - ] | ( \d + ) \. ) ( \s * ) $ / ,
1516 unorderedBullets = "*+-" ;
1617
1718 CodeMirror . commands . newlineAndIndentContinueMarkdownList = function ( cm ) {
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 ) ;
You can’t perform that action at this time.
0 commit comments