Skip to content

Commit 7827c39

Browse files
committed
Make code more consistent
1 parent 95c201e commit 7827c39

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ function undoUnorderedListStyle(text: string): UndoResult {
637637
}
638638
}
639639

640-
const prefix = (index: number, unorderedList: boolean): string => {
640+
function makePrefix(index: number, unorderedList: boolean): string {
641641
if (unorderedList) {
642642
return '- '
643643
} else {
@@ -671,20 +671,20 @@ function listStyle(textarea: HTMLTextAreaElement, style: StyleArgs): SelectionRa
671671
}
672672

673673
const lines = selectedText.split('\n').map((value, index) => {
674-
return `${prefix(index, style.unorderedList)}${value}`
674+
return `${makePrefix(index, style.unorderedList)}${value}`
675675
})
676676

677677
const totalPrefixLength = lines.reduce((previousValue, currentValue, currentIndex) => {
678-
return previousValue + prefix(currentIndex, style.unorderedList).length
678+
return previousValue + makePrefix(currentIndex, style.unorderedList).length
679679
}, 0)
680680

681681
const totalPrefixLengthOpositeList = lines.reduce((previousValue, currentValue, currentIndex) => {
682-
return previousValue + prefix(currentIndex, !style.unorderedList).length
682+
return previousValue + makePrefix(currentIndex, !style.unorderedList).length
683683
}, 0)
684684

685685
if (undoResult.processed) {
686686
if (noInitialSelection) {
687-
selectionStart = Math.max(selectionStart - prefix(0, style.unorderedList).length, 0)
687+
selectionStart = Math.max(selectionStart - makePrefix(0, style.unorderedList).length, 0)
688688
selectionEnd = selectionStart
689689
} else {
690690
selectionStart = textarea.selectionStart
@@ -696,7 +696,7 @@ function listStyle(textarea: HTMLTextAreaElement, style: StyleArgs): SelectionRa
696696
const {newlinesToAppend, newlinesToPrepend} = newlinesToSurroundSelectedText(textarea)
697697

698698
if (noInitialSelection) {
699-
selectionStart = Math.max(selectionStart + prefix(0, style.unorderedList).length + newlinesToAppend.length, 0)
699+
selectionStart = Math.max(selectionStart + makePrefix(0, style.unorderedList).length + newlinesToAppend.length, 0)
700700
selectionEnd = selectionStart
701701
} else {
702702
if (undoResultOpositeList.processed) {

0 commit comments

Comments
 (0)