Skip to content

Commit 3f2714b

Browse files
committed
Update version to 0.2.4; added emoji support
1 parent 17446f0 commit 3f2714b

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,8 @@
9494

9595
## 0.2.3
9696

97-
* Added Option to enable/disable LSP warning and error.
97+
* Added Option to enable/disable LSP warning and error.
98+
99+
## 0.2.4
100+
101+
* Added Emoji support

lib/code_crafter/code_crafter_controller.dart

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_code_crafter
22
description: "Powerful code editor with AI code completion and LSP support"
3-
version: 0.2.3
3+
version: 0.2.4
44
homepage: https://github.com/heckmon/flutter_code_crafter
55

66
environment:

0 commit comments

Comments
 (0)