Skip to content

Commit fbc51fa

Browse files
committed
skip escaped
1 parent 7025a2c commit fbc51fa

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

extensions-builtin/prompt-bracket-checker/javascript/prompt-bracket-checker.js

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,18 @@
2424
char = textArea.value[i];
2525
}
2626

27-
for (const [open, close, label] of pairs) {
28-
const lb = escaped ? `escaped ${label}` : label;
27+
if (escaped) {
28+
i++;
29+
continue;
30+
}
2931

32+
for (const [open, close, label] of pairs) {
3033
if (char === open) {
31-
counts[lb] = (counts[lb] || 0) + 1;
34+
counts[label] = (counts[label] || 0) + 1;
3235
} else if (char === close) {
33-
counts[lb] = (counts[lb] || 0) - 1;
34-
if (counts[lb] < 0) {
35-
errors.add(`Incorrect order of ${lb}.`);
36+
counts[label] = (counts[label] || 0) - 1;
37+
if (counts[label] < 0) {
38+
errors.add(`Incorrect order of ${label}.`);
3639
}
3740
}
3841
}
@@ -52,21 +55,6 @@
5255
}
5356
}
5457

55-
for (const [open, close, label] of pairs) {
56-
const lb = `escaped ${label}`;
57-
if (counts[lb] == undefined) {
58-
continue;
59-
}
60-
61-
const op = `\\${open}`;
62-
const cl = `\\${close}`;
63-
if (counts[lb] > 0) {
64-
errors.add(`${op} ... ${cl} - Detected ${counts[lb]} more opening than closing ${lb}.`);
65-
} else if (counts[lb] < 0) {
66-
errors.add(`${op} ... ${cl} - Detected ${-counts[lb]} more closing than opening ${lb}.`);
67-
}
68-
}
69-
7058
counterElem.title = [...errors].join('\n');
7159
counterElem.classList.toggle('error', errors.size !== 0);
7260
}

0 commit comments

Comments
 (0)