Skip to content

Commit 321551e

Browse files
committed
Add ISSUE-6312 search markers
1 parent d7a7d82 commit 321551e

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

sdk/python/packages/flet-code-editor/src/flutter/flet_code_editor/lib/src/utils/flet_code_controller.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ import 'package:highlight/languages/json.dart';
55
import 'json_analyzer.dart';
66

77
class FletCodeController extends fce.CodeController {
8+
// ISSUE-6312: Use a dedicated analyzer for JSON so invalid JSON can surface
9+
// gutter markers instead of falling back to the default fold-only analyzer.
810
FletCodeController({super.text, super.language})
911
: super(analyzer: _analyzerForLanguage(language));
1012

1113
bool autocompletionEnabled = false;
1214

1315
static fce.AbstractAnalyzer _analyzerForLanguage(dynamic language) {
16+
// ISSUE-6312: Keep existing behavior for other languages and only switch
17+
// JSON to the custom analyzer added for this bug fix.
1418
return language != json
1519
? const fce.DefaultLocalAnalyzer()
1620
: const JsonLocalAnalyzer();

sdk/python/packages/flet-code-editor/src/flutter/flet_code_editor/lib/src/utils/json_analyzer.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import 'dart:convert';
22

33
import 'package:flutter_code_editor/flutter_code_editor.dart' as fce;
44

5+
// ISSUE-6312: JSON syntax errors were not converted into editor issues, so the
6+
// gutter had nothing to render. This analyzer adds real JSON validation.
57
class JsonLocalAnalyzer extends fce.AbstractAnalyzer {
68
const JsonLocalAnalyzer();
79

@@ -18,6 +20,7 @@ class JsonLocalAnalyzer extends fce.AbstractAnalyzer {
1820
try {
1921
jsonDecode(code.text);
2022
} on FormatException catch (error) {
23+
// ISSUE-6312: Translate JSON parsing failures into gutter-visible issues.
2124
issues.add(
2225
fce.Issue(
2326
line: _lineFromOffset(code.text, error.offset),
@@ -31,6 +34,8 @@ class JsonLocalAnalyzer extends fce.AbstractAnalyzer {
3134
}
3235

3336
int _lineFromOffset(String text, int? offset) {
37+
// ISSUE-6312: Map the parser offset back to a line number for gutter
38+
// rendering.
3439
final safeOffset = (offset ?? 0).clamp(0, text.length);
3540
return '\n'.allMatches(text.substring(0, safeOffset)).length;
3641
}

sdk/python/packages/flet-code-editor/src/flutter/flet_code_editor/test/json_gutter_analyzer_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'package:flet_code_editor/src/utils/flet_code_controller.dart';
66
import 'package:flet_code_editor/src/utils/json_analyzer.dart';
77

88
void main() {
9+
// ISSUE-6312: Regression coverage for missing JSON gutter error markers.
910
group('FletCodeController JSON analyzer', () {
1011
test('uses JSON analyzer for JSON language', () {
1112
final controller = FletCodeController(

0 commit comments

Comments
 (0)