]> git.eshelyaron.com Git - emacs.git/commitdiff
csharp-mode.el: Improve fontification of string-interpolation exprs
authorJostein Kjønigsen <jostein@kjonigsen.net>
Wed, 23 Apr 2025 08:32:30 +0000 (10:32 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sat, 26 Apr 2025 17:37:05 +0000 (19:37 +0200)
* lisp/progmodes/csharp-mode.el
(csharp-ts-mode--font-lock-settings): Remove too wide selector,
causing non-string content to be fonitified as strings.  Add
additional eselectors to highlight variables inside
interpolation-expressions too.  (Bug#78008)

(cherry picked from commit 67e8351bdb78eadaf07a5b308806ec3c00c9e979)

lisp/progmodes/csharp-mode.el

index a421d616d9b5c175e0bca7e56443a493f19f38fc..e002391d3057129c360bf253d4b6f20c42f707c6 100644 (file)
@@ -777,11 +777,19 @@ compilation and evaluation time conflicts."
    :feature 'expression
    '((conditional_expression (identifier) @font-lock-variable-use-face)
      (postfix_unary_expression (identifier)* @font-lock-variable-use-face)
-     (initializer_expression (assignment_expression left: (identifier) @font-lock-variable-use-face)))
+     (initializer_expression (assignment_expression left: (identifier) @font-lock-variable-use-face))
+     (interpolated_string_expression
+      (interpolation
+       (identifier) @font-lock-variable-use-face))
+     (interpolated_string_expression
+      (interpolation
+       (member_access_expression
+        expression: (identifier) @font-lock-variable-use-face
+        name: (identifier) @font-lock-property-use-face))))
 
    :language 'c-sharp
    :feature 'bracket
-   '((["(" ")" "[" "]" "{" "}"]) @font-lock-bracket-face)
+   '((["(" ")" "[" "]" "{" "}" (interpolation_brace)]) @font-lock-bracket-face)
 
    :language 'c-sharp
    :feature 'delimiter
@@ -839,8 +847,7 @@ compilation and evaluation time conflicts."
               "$\""
               "@$\""
               "$@\"")
-          '((interpolated_string_expression)
-            (interpolation_start)
+          '((interpolation_start)
             (interpolation_quote)))]
      @font-lock-string-face)