@@ -240,7 +240,8 @@ like ::, class, instance, data, newtype, type."
240
240
(token nil )
241
241
; ; we are starting right after ::
242
242
(last-token-was-operator t )
243
- (last-token-was-newline nil ))
243
+ (last-token-was-newline nil )
244
+ (open-parens 0 ))
244
245
(while cont
245
246
(setq token (haskell-lexeme-looking-at-token 'newline ))
246
247
@@ -251,9 +252,26 @@ like ::, class, instance, data, newtype, type."
251
252
(setq last-token-was-newline (not last-token-was-operator))
252
253
(setq end (match-end 0 ))
253
254
(goto-char (match-end 0 )))
255
+ ((member (match-string-no-properties 0 )
256
+ '(" )" " ]" " }" ))
257
+ (setq open-parens (1- open-parens))
258
+ (if (< open-parens 0 )
259
+ ; ; unmatched closing parenthesis closes type declaration
260
+ (setq cont nil )
261
+ (setq end (match-end 0 ))
262
+ (goto-char end))
263
+ (setq last-token-was-newline nil ))
264
+ ((and (member (match-string-no-properties 0 )
265
+ '(" ," " ;" " |" ))
266
+ (not (member (match-string-no-properties 0 ) ignore)))
267
+ (if (equal 0 open-parens)
268
+ (setq cont nil )
269
+ (setq last-token-was-operator t )
270
+ (setq end (match-end 0 ))
271
+ (goto-char end))
272
+ (setq last-token-was-newline nil ))
254
273
((and (or (member (match-string-no-properties 0 )
255
- '(" <-" " =" " <-" " ←" " ," " ;"
256
- " )" " ]" " }" " |" ))
274
+ '(" <-" " =" " ←" ))
257
275
(member (match-string-no-properties 0 ) haskell-font-lock--reverved-ids))
258
276
(not (member (match-string-no-properties 0 ) ignore)))
259
277
(setq cont nil )
@@ -262,11 +280,9 @@ like ::, class, instance, data, newtype, type."
262
280
'(" (" " [" " {" ))
263
281
(if last-token-was-newline
264
282
(setq cont nil )
265
- (goto-char (match-beginning 0 ))
266
- (condition-case err
267
- (forward-sexp )
268
- (scan-error (goto-char (nth 3 err))))
269
- (setq end (point ))
283
+ (setq open-parens (1+ open-parens))
284
+ (setq end (match-end 0 ))
285
+ (goto-char end)
270
286
(setq last-token-was-newline nil )))
271
287
((member token '(qsymid char string number template-haskell-quote template-haskell-quasi-quote))
272
288
(setq last-token-was-operator (member (haskell-lexeme-classify-by-first-char (char-after (match-beginning 1 )))
0 commit comments