File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed
Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -2,9 +2,11 @@ import 'package:highlight/highlight_core.dart';
22import 'package:highlight/languages/dart.dart' ;
33import 'package:highlight/languages/go.dart' ;
44import 'package:highlight/languages/java.dart' ;
5+ import 'package:highlight/languages/javascript.dart' ;
56import 'package:highlight/languages/php.dart' ;
67import 'package:highlight/languages/python.dart' ;
78import 'package:highlight/languages/scala.dart' ;
9+ import 'package:highlight/languages/typescript.dart' ;
810import 'package:highlight/languages/vhdl.dart' ;
911
1012class SingleLineComments {
@@ -18,6 +20,8 @@ class SingleLineComments {
1820 python: [_hash],
1921 scala: [_slashes],
2022 vhdl: [_hyphenMinuses],
23+ typescript: [_slashes],
24+ javascript: [_slashes],
2125 };
2226
2327 static const _slashes = '//' ;
Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ import 'package:flutter_code_editor/src/named_sections/parsers/brackets_start_en
33import 'package:flutter_test/flutter_test.dart' ;
44import 'package:highlight/languages/angelscript.dart' ;
55import 'package:highlight/languages/java.dart' ;
6+ import 'package:highlight/languages/javascript.dart' ;
7+ import 'package:highlight/languages/typescript.dart' ;
68
79final _language = java;
810
@@ -102,5 +104,55 @@ public class MyClass {
102104 expected,
103105 );
104106 });
107+
108+ test ('Lines in read-only sections are read-only for JS/TS Language' , () {
109+ const text = '''
110+ export class MyTypeScriptClass {
111+ run() { // [START section1]
112+ }
113+ // [END section1]
114+ // [START section2]
115+ method() {
116+ }
117+ // [END section2]
118+ }
119+ ''' ;
120+ const expected = [
121+ false ,
122+ true ,
123+ true ,
124+ true ,
125+ false ,
126+ false ,
127+ false ,
128+ false ,
129+ false ,
130+ false ,
131+ ];
132+
133+ final codeTypescript = Code (
134+ text: text,
135+ namedSectionParser: const BracketsStartEndNamedSectionParser (),
136+ readOnlySectionNames: {'section1' , 'nonexistent' },
137+ language: typescript,
138+ );
139+
140+ final codeJavascript = Code (
141+ text: text,
142+ namedSectionParser: const BracketsStartEndNamedSectionParser (),
143+ readOnlySectionNames: {'section1' , 'nonexistent' },
144+ language: javascript,
145+ );
146+
147+ expect (
148+ codeTypescript.lines.lines.map ((line) => line.isReadOnly),
149+ expected,
150+ );
151+
152+ expect (
153+ codeJavascript.lines.lines.map ((line) => line.isReadOnly),
154+ expected,
155+ );
156+ });
105157 });
106158}
You can’t perform that action at this time.
0 commit comments