File tree Expand file tree Collapse file tree 2 files changed +26
-5
lines changed
Expand file tree Collapse file tree 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) {
175175 var name = readSymbol ( stream ) ;
176176 tokenType = "symbol" ;
177177
178+ if ( is ( name , "comment" ) && is ( state . lastToken , "(" ) )
179+ return ( state . tokenize = inComment ) ( stream , state ) ;
178180 if ( is ( name , atom ) || is ( name . charAt ( 0 ) , ":" ) ) return "atom" ;
179181 if ( is ( name , specialForm ) || is ( name , coreSymbol ) ) return "keyword" ;
180182 if ( is ( state . lastToken , "(" ) ) return "builtin" ; // other head symbol
@@ -193,6 +195,25 @@ CodeMirror.defineMode("clojure", function (options) {
193195 return "string" ;
194196 }
195197
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+
196217 function readSymbol ( stream ) {
197218 var ch ;
198219
Original file line number Diff line number Diff line change 7575
7676 MT ( "comments" ,
7777 "[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 )]"
8181 ) ;
8282
8383 MT ( "reader macro characters" ,
309309 ) ;
310310
311311 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 )]"
314314 ) ;
315315
316316 MT ( "should indent cond" ,
You can’t perform that action at this time.
0 commit comments