@@ -678,19 +678,6 @@ function listStyle(textarea: HTMLTextAreaElement, style: StyleArgs): SelectionRa
678678 selectedText = undoOrderedListStyle ( undoResult . text ) . text
679679 }
680680
681- if ( undoResult . processed ) {
682- // // if (noInitialSelection) {
683- // // selectionStart = Math.max(selectionStart - prefix.length, 0)
684- // // selectionEnd = selectionStart
685- // // } else {
686- // // selectionStart = Math.max(selectionStart - prefix.length, 0)
687- // // selectionEnd = selectionEnd + prefix.length // * lines.length
688- // // }
689- return { text : undoResult . text , selectionStart, selectionEnd}
690- }
691-
692- // selectedText = undoResult.text
693-
694681 const lines = selectedText . split ( '\n' ) . map ( ( value , index ) => {
695682 return `${ prefix ( index ) } ${ value } `
696683 } )
@@ -699,6 +686,17 @@ function listStyle(textarea: HTMLTextAreaElement, style: StyleArgs): SelectionRa
699686 return previousValue + prefix ( currentIndex ) . length
700687 } , 0 )
701688
689+ if ( undoResult . processed ) {
690+ if ( noInitialSelection ) {
691+ selectionStart = Math . max ( selectionStart - prefix ( 0 ) . length , 0 )
692+ selectionEnd = selectionStart
693+ } else {
694+ selectionStart = Math . max ( selectionStart - prefix . length , 0 )
695+ selectionEnd = selectionEnd + totalPrefixLength
696+ }
697+ return { text : undoResult . text , selectionStart, selectionEnd}
698+ }
699+
702700 const { newlinesToAppend, newlinesToPrepend} = newlinesToSurroundSelectedText ( textarea )
703701
704702 if ( noInitialSelection ) {
0 commit comments