Skip to content

Commit a01999c

Browse files
committed
feat: update version to 0.3.0; fix text parsing and folding issues
1 parent aa4afa4 commit a01999c

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

CHANGELOG.md

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

122122
## 0.2.9
123123

124-
* Fix: Removed grapheme characters
124+
* Fix: Removed grapheme characters
125+
126+
## 0.3.0
127+
128+
* Fix: folding issue

lib/code_crafter/code_crafter_controller.dart

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,15 +349,17 @@ class CodeCrafterController extends TextEditingController {
349349
}
350350
}
351351

352-
final List<Node>? nodes = highlight.parse(text, language: _langId).nodes;
352+
final newText = lines.join('\n');
353+
354+
final List<Node>? nodes = highlight.parse(newText, language: _langId).nodes;
353355
final Set<int> unmatchedBrackets = _findUnmatchedBrackets(text);
354356
if (nodes != null && editorTheme.isNotEmpty) {
355357
return TextSpan(
356358
style: baseStyle,
357359
children: _convert(nodes, 0, bracket1, bracket2, unmatchedBrackets),
358360
);
359361
} else {
360-
return TextSpan(text: text, style: textStyle);
362+
return TextSpan(text: newText, style: textStyle);
361363
}
362364
}
363365

@@ -377,7 +379,10 @@ class CodeCrafterController extends TextEditingController {
377379
for (int lineIdx = 0; lineIdx < nodeLines.length; lineIdx++) {
378380
final line = nodeLines[lineIdx];
379381
final startOfLineOffset = offset;
380-
offset += line.length + (lineIdx == nodeLines.length - 1 ? 0 : 1);
382+
final lineChars = line.characters;
383+
offset +=
384+
lineChars.length + (lineIdx == nodeLines.length - 1 ? 0 : 1);
385+
381386
final match = RegExp(r'^(\s*)').firstMatch(line);
382387
final leading = match?.group(0) ?? '';
383388
final indentLen = leading.length;
@@ -389,9 +394,9 @@ class CodeCrafterController extends TextEditingController {
389394
String accumulatedText = '';
390395
TextStyle? currentStyle;
391396

392-
for (int col = 0; col < line.length; col++) {
397+
for (int col = 0; col < lineChars.length; col++) {
393398
final globalIdx = startOfLineOffset + col;
394-
String ch = line[col];
399+
String ch = lineChars.elementAt(col);
395400
if (ch == ' ' && guideCols.contains(col)) ch = '│';
396401

397402
final bool isMatch = globalIdx == b1 || globalIdx == b2;

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.9
3+
version: 0.3.0
44
homepage: https://github.com/heckmon/flutter_code_crafter
55

66
environment:

0 commit comments

Comments
 (0)