File tree 2 files changed +56
-0
lines changed
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';
2
2
import 'package:highlight/languages/dart.dart' ;
3
3
import 'package:highlight/languages/go.dart' ;
4
4
import 'package:highlight/languages/java.dart' ;
5
+ import 'package:highlight/languages/javascript.dart' ;
5
6
import 'package:highlight/languages/php.dart' ;
6
7
import 'package:highlight/languages/python.dart' ;
7
8
import 'package:highlight/languages/scala.dart' ;
9
+ import 'package:highlight/languages/typescript.dart' ;
8
10
import 'package:highlight/languages/vhdl.dart' ;
9
11
10
12
class SingleLineComments {
@@ -18,6 +20,8 @@ class SingleLineComments {
18
20
python: [_hash],
19
21
scala: [_slashes],
20
22
vhdl: [_hyphenMinuses],
23
+ typescript: [_slashes],
24
+ javascript: [_slashes],
21
25
};
22
26
23
27
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
3
3
import 'package:flutter_test/flutter_test.dart' ;
4
4
import 'package:highlight/languages/angelscript.dart' ;
5
5
import 'package:highlight/languages/java.dart' ;
6
+ import 'package:highlight/languages/javascript.dart' ;
7
+ import 'package:highlight/languages/typescript.dart' ;
6
8
7
9
final _language = java;
8
10
@@ -102,5 +104,55 @@ public class MyClass {
102
104
expected,
103
105
);
104
106
});
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
+ });
105
157
});
106
158
}
You can’t perform that action at this time.
0 commit comments