File tree 2 files changed +26
-5
lines changed 2 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -175,6 +175,8 @@ CodeMirror.defineMode("clojure", function (options) {
175
175
var name = readSymbol ( stream ) ;
176
176
tokenType = "symbol" ;
177
177
178
+ if ( is ( name , "comment" ) && is ( state . lastToken , "(" ) )
179
+ return ( state . tokenize = inComment ) ( stream , state ) ;
178
180
if ( is ( name , atom ) || is ( name . charAt ( 0 ) , ":" ) ) return "atom" ;
179
181
if ( is ( name , specialForm ) || is ( name , coreSymbol ) ) return "keyword" ;
180
182
if ( is ( state . lastToken , "(" ) ) return "builtin" ; // other head symbol
@@ -193,6 +195,25 @@ CodeMirror.defineMode("clojure", function (options) {
193
195
return "string" ;
194
196
}
195
197
198
+ function inComment ( stream , state ) {
199
+ var parenthesisCount = 1 ;
200
+ var next ;
201
+
202
+ while ( next = stream . next ( ) ) {
203
+ if ( is ( next , ")" ) ) parenthesisCount -- ;
204
+ if ( is ( next , "(" ) ) parenthesisCount ++ ;
205
+ if ( is ( parenthesisCount , 0 ) ) {
206
+ stream . backUp ( 1 ) ;
207
+ state . tokenize = base ;
208
+ break ;
209
+ }
210
+ }
211
+
212
+ tokenType = "ws" ;
213
+
214
+ return "comment" ;
215
+ }
216
+
196
217
function readSymbol ( stream ) {
197
218
var ch ;
198
219
Original file line number Diff line number Diff line change 75
75
76
76
MT ( "comments" ,
77
77
"[comment ; this is an in-line comment.]" ,
78
- "[comment ;; this is a line comment.]"
79
- // FIXME
80
- // "[bracket (][comment comment] [comment (][comment foo] [comment 1] [comment 2] [comment 3][comment )][bracket )]"
78
+ "[comment ;; this is a line comment.]" ,
79
+ "[keyword comment]" ,
80
+ "[bracket (][comment comment ( foo 1 2 3 )][bracket )]"
81
81
) ;
82
82
83
83
MT ( "reader macro characters" ,
309
309
) ;
310
310
311
311
MT ( "should indent comment" ,
312
- "[bracket (][keyword comment] [bracket (][builtin foo][bracket )]" ,
313
- " [bracket (][builtin bar] [number 1] [number 2] [number 3 ][bracket ) )]"
312
+ "[bracket (][comment comment ( foo)]" ,
313
+ "[comment ( bar 1 2 3) ][bracket )]"
314
314
) ;
315
315
316
316
MT ( "should indent cond" ,
You can’t perform that action at this time.
0 commit comments