File tree Expand file tree Collapse file tree
app/src/processing/app/syntax Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,19 +16,12 @@ public void invalidate() {
1616 }
1717
1818 public int findMatchingBracket (final String text , final int pos ) {
19- if (offsets == null )
20- parse (text );
21- // find this bracket
22- int p ;
23- for (p = 0 ; p < offsets .size (); p ++)
24- if (offsets .get (p ) == pos )
25- break ;
26- if (p == offsets .size ()) {
19+ if (pos < 0 || pos > text .length ())
2720 return -1 ;
28- }
29- final int direction ;
30- final char alpha = text .charAt (offsets .get (p ));
21+
22+ final char alpha = text .charAt (pos );
3123 final char beta ;
24+ final int direction ;
3225 switch (alpha ) {
3326 case '(' :
3427 beta = ')' ;
@@ -55,9 +48,21 @@ public int findMatchingBracket(final String text, final int pos) {
5548 direction = -1 ;
5649 break ;
5750 default :
58- System .err .println ("Unexpected char " + alpha + " at position " + p );
5951 return -1 ;
6052 }
53+
54+ if (offsets == null )
55+ parse (text );
56+
57+ // find this bracket
58+ int p ;
59+ for (p = 0 ; p < offsets .size (); p ++)
60+ if (offsets .get (p ) == pos )
61+ break ;
62+ if (p == offsets .size ()) {
63+ return -1 ;
64+ }
65+
6166 int depth = 1 ;
6267 for (p += direction ; p >= 0 && p < offsets .size (); p += direction ) {
6368 final int offset = offsets .get (p );
You can’t perform that action at this time.
0 commit comments