Skip to content

Commit 5e51a08

Browse files
committed
fix util.ts
1 parent 3d64059 commit 5e51a08

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/common/util.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -309,27 +309,28 @@ export function _defaultSplittableCommandFormatter(cmd: string): string {
309309
splitFill(null, srcChar)
310310
} else {
311311
let startNewCmdKey = false
312-
for (let j in srcChar) {
313-
if (srcChar[j] === ',') {
314-
splitFill('t-cmd-splitter', srcChar[j])
315-
} else if (srcChar[j] === '|') {
316-
splitFill(null, srcChar[j])
312+
const charArr: string[] = [...srcChar]
313+
charArr.forEach((ch, j) => {
314+
if (ch === ',') {
315+
splitFill('t-cmd-splitter', ch)
316+
} else if (ch === '|') {
317+
splitFill(null, ch)
317318

318319
isCmdKey = true
319-
if (j < srcChar.length - 1) {
320+
if (j < charArr.length - 1) {
320321
startNewCmdKey = true
321322
}
322323
} else {
323324
if (startNewCmdKey) {
324-
splitFill('t-cmd-key', srcChar[j])
325+
splitFill('t-cmd-key', ch)
325326
} else {
326-
splitFill(null, srcChar[j])
327+
splitFill(null, ch)
327328
}
328329
}
329-
if (j === srcChar.length - 1 && srcChar[j] !== '|') {
330+
if (j === charArr.length - 1 && ch !== '|') {
330331
isCmdKey = false
331332
}
332-
}
333+
})
333334
}
334335
}
335336
if (i < split.length - 1) {

0 commit comments

Comments
 (0)