@@ -1015,7 +1015,7 @@ lines."
1015
1015
(progn
1016
1016
(forward-comment most-positive-fixnum)
1017
1017
(memq (char-after ) '(?\, ?\; ?\] ?\) ?\} ))))
1018
- do (forward-sexp )))
1018
+ do (forward-sexp )))
1019
1019
while (and (eq (char-after ) ?\n )
1020
1020
(save-excursion
1021
1021
(forward-char )
@@ -1686,6 +1686,33 @@ point of view of font-lock. It applies highlighting directly with
1686
1686
; ; Matcher always "fails"
1687
1687
nil )
1688
1688
1689
+ (defun typescript--function-argument-matcher (limit )
1690
+ (condition-case nil
1691
+ (save-restriction
1692
+ (widen )
1693
+ (narrow-to-region (point-min ) limit)
1694
+ (while (re-search-forward (rx (group (regexp typescript--name-re))
1695
+ (* whitespace)
1696
+ (group (or " ," " :" " )" )))
1697
+ nil t )
1698
+ (font-lock-apply-highlight '(1 font-lock-variable-name-face t ))
1699
+
1700
+ (let ((ender (match-string 2 )))
1701
+ ; ; we need to skip the type specification
1702
+ (when (equal ender " :" )
1703
+ (when (re-search-forward (rx (or (and " ," eol)
1704
+ (and " )" )
1705
+ (and " ,"
1706
+ (* whitespace)
1707
+ (regexp typescript--name-re)
1708
+ (group (or " :" " )" )))))
1709
+ nil t )
1710
+ (goto-char (match-beginning 0 )))))))
1711
+ ; ; Conditions to handle
1712
+ (scan-error nil )
1713
+ (end-of-buffer nil ))
1714
+ nil )
1715
+
1689
1716
(defun typescript--in-documentation-comment-p ()
1690
1717
" Reports whether point is inside a documentation comment."
1691
1718
(let ((parse (syntax-ppss )))
@@ -1864,7 +1891,27 @@ and searches for the next token to be highlighted."
1864
1891
(prog1 (save-excursion (re-search-forward " )" nil t ))
1865
1892
(backward-char ))
1866
1893
nil
1867
- (1 font-lock-variable-name-face ))))
1894
+ (1 font-lock-variable-name-face )))
1895
+
1896
+ ; ; formal parameters in arrow function
1897
+ ,(list
1898
+ (rx (group " =>" ) (* whitespace) (? eol) (* whitespace) " {" )
1899
+ '(1 font-lock-keyword-face )
1900
+ `(; ; ,(rx (group (regexp typescript--name-re))
1901
+ ; ; (* whitespace)
1902
+ ; ; (? ":" (* whitespace) (regexp typescript--name-re) (* whitespace))
1903
+ ; ; (or "," ")" eol))
1904
+ typescript--function-argument-matcher
1905
+ (prog1 (progn
1906
+ (backward-char )
1907
+ (typescript--backward-to-parameter-list)
1908
+ (point ))
1909
+ (backward-sexp ))
1910
+ (re-search-forward " {" nil t )
1911
+ nil
1912
+ ; ; (1 font-lock-variable-name-face t t)
1913
+ ))
1914
+ )
1868
1915
" Level three font lock for `typescript-mode' ." )
1869
1916
1870
1917
(defun typescript--flyspell-mode-predicate ()
0 commit comments