Skip to content

Commit db8ea8d

Browse files
rectangular-zonejuergenhoetzel
authored andcommitted
Update attribute font locking
Previously, attributes like `[<EntryPoint>]` would lock just fine, while attributes like `[<Options("arg")>]` would fail to lock at all. This was because the regex couldn't handle the parens and inner string, so would skip the whole match. This commit fixes that, making sure the parens lock in the same face as the rest of the attribute, while any provided inner properties lock as a string.
1 parent 49756cb commit db8ea8d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

fsharp-mode-font.el

+6-4
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,8 @@ with initial value INITVALUE and optional DOCSTRING."
153153
"\\([A-Za-z_][A-Za-z0-9_']*\\)\\s-*:\\s-*\\([A-Za-z_][A-Za-z0-9_'<> \t]*\\)"))
154154

155155
(def-fsharp-compiled-var fsharp-attributes-regexp
156-
"\\[<[A-Za-z0-9_]+>\\]"
157-
"Match attributes like [<EntryPoint>]")
158-
156+
"\\(\\[<[A-Za-z0-9_]+(?\\)\\(\".*\"\\)?\\()?>\\]\\)"
157+
"Match attributes like [<EntryPoint>]; separately groups contained strings in attributes like [<Attribute(\"property\")>]")
159158

160159
;; F# makes extensive use of operators, many of which have some kind of
161160
;; structural significance.
@@ -286,7 +285,10 @@ with initial value INITVALUE and optional DOCSTRING."
286285
(1 font-lock-comment-face)
287286
(2 font-lock-keyword-face))
288287
;; attributes
289-
(,fsharp-attributes-regexp . font-lock-preprocessor-face)
288+
(,fsharp-attributes-regexp
289+
(1 font-lock-preprocessor-face)
290+
(2 font-lock-string-face)
291+
(3 font-lock-preprocessor-face))
290292
;; ;; type defines
291293
(,fsharp-type-def-regexp 1 font-lock-type-face)
292294
(,fsharp-function-def-regexp 1 font-lock-function-name-face)

0 commit comments

Comments
 (0)