File tree Expand file tree Collapse file tree 1 file changed +9
-21
lines changed
extensions-builtin/prompt-bracket-checker/javascript Expand file tree Collapse file tree 1 file changed +9
-21
lines changed Original file line number Diff line number Diff line change 24
24
char = textArea . value [ i ] ;
25
25
}
26
26
27
- for ( const [ open , close , label ] of pairs ) {
28
- const lb = escaped ? `escaped ${ label } ` : label ;
27
+ if ( escaped ) {
28
+ i ++ ;
29
+ continue ;
30
+ }
29
31
32
+ for ( const [ open , close , label ] of pairs ) {
30
33
if ( char === open ) {
31
- counts [ lb ] = ( counts [ lb ] || 0 ) + 1 ;
34
+ counts [ label ] = ( counts [ label ] || 0 ) + 1 ;
32
35
} 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 } .` ) ;
36
39
}
37
40
}
38
41
}
52
55
}
53
56
}
54
57
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
-
70
58
counterElem . title = [ ...errors ] . join ( '\n' ) ;
71
59
counterElem . classList . toggle ( 'error' , errors . size !== 0 ) ;
72
60
}
You can’t perform that action at this time.
0 commit comments