@@ -134,8 +134,9 @@ class CodeCrafterController extends TextEditingController {
134134
135135 String ? currentStringQuote;
136136
137- for (int i = 0 ; i < text.length; i++ ) {
138- final char = text[i];
137+ final chars = text.characters;
138+ for (int i = 0 ; i < chars.length; i++ ) {
139+ final char = chars.elementAt (i);
139140
140141 if (char == '"' || char == "'" ) {
141142 if (currentStringQuote == null ) {
@@ -180,27 +181,27 @@ class CodeCrafterController extends TextEditingController {
180181 };
181182 const String openers = '({[' ;
182183
183- if (pos < 0 || pos >= text.length) return null ;
184+ if (pos < 0 || pos >= text.characters. length) return null ;
184185
185- final char = text[ pos] ;
186+ final char = text.characters. elementAt ( pos) ;
186187 if (! pairs.containsKey (char)) return null ;
187188
188189 final match = pairs[char]! ;
189190 final isForward = openers.contains (char);
190191
191192 int depth = 0 ;
192193 if (isForward) {
193- for (int i = pos + 1 ; i < text.length; i++ ) {
194- if (text[i] == char) depth++ ;
195- if (text[i] == match) {
194+ for (int i = pos + 1 ; i < text.characters. length; i++ ) {
195+ if (text.characters. elementAt (i) == char) depth++ ;
196+ if (text.characters. elementAt (i) == match) {
196197 if (depth == 0 ) return i;
197198 depth-- ;
198199 }
199200 }
200201 } else {
201202 for (int i = pos - 1 ; i >= 0 ; i-- ) {
202- if (text[i] == char) depth++ ;
203- if (text[i] == match) {
203+ if (text.characters. elementAt (i) == char) depth++ ;
204+ if (text.characters. elementAt (i) == match) {
204205 if (depth == 0 ) return i;
205206 depth-- ;
206207 }
@@ -375,17 +376,19 @@ class CodeCrafterController extends TextEditingController {
375376 for (int lineIdx = 0 ; lineIdx < nodeLines.length; lineIdx++ ) {
376377 final line = nodeLines[lineIdx];
377378 final startOfLineOffset = offset;
378- offset += line.length + (lineIdx == nodeLines.length - 1 ? 0 : 1 );
379+ final lineChars = line.characters;
380+ offset +=
381+ lineChars.length + (lineIdx == nodeLines.length - 1 ? 0 : 1 );
379382 final match = RegExp (r'^(\s*)' ).firstMatch (line);
380383 final leading = match? .group (0 ) ?? '' ;
381384 final indentLen = leading.length;
382385 final indentLvl = indentLen ~ / Shared ().tabSize;
383386 final Set <int > guideCols = {
384387 for (int k = 0 ; k < indentLvl; k++ ) k * Shared ().tabSize,
385388 };
386- for (int col = 0 ; col < line .length; col++ ) {
389+ for (int col = 0 ; col < lineChars .length; col++ ) {
387390 final globalIdx = startOfLineOffset + col;
388- String ch = line[ col] ;
391+ String ch = lineChars. elementAt ( col) ;
389392 if (ch == ' ' && guideCols.contains (col)) ch = '│' ;
390393 final bool isMatch = globalIdx == b1 || globalIdx == b2;
391394 final bool isUnmatched = unmatched.contains (globalIdx);
0 commit comments