We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
getMultiCodePointCharacters
1 parent bf137a8 commit 1a1d672Copy full SHA for 1a1d672
src/utils/strings.ts
@@ -17,15 +17,27 @@ export function getMultiCodePointCharacters(text: string): string[] {
17
if (matched?.includes("\x1b")) {
18
const arr: string[] = [];
19
let i = 0;
20
- let ansi = false;
+ let ansi = 0;
21
+ let lastStyle = "";
22
for (const char of matched) {
23
arr[i] ??= "";
- arr[i] += char;
24
+ arr[i] += lastStyle + char;
25
26
if (char === "\x1b") {
- ansi = true;
27
+ ++ansi;
28
+ lastStyle += "\x1b";
29
} else if (ansi) {
- if (char === "m") ansi = false;
30
+ lastStyle += char;
31
+
32
+ if (ansi === 3 && char === "m" && lastStyle[lastStyle.length - 2] === "0") {
33
+ lastStyle = "";
34
+ }
35
36
+ if (char === "m") {
37
+ ansi = 0;
38
+ } else {
39
40
41
} else {
42
++i;
43
}
0 commit comments