From: Jostein Kjønigsen Date: Sat, 1 Feb 2025 21:16:36 +0000 (+0100) Subject: lisp/progmodes/csharp-mode.el: Improve string-interpolation X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=629bab2a4a946e7c281993d05f6ea19d848e17da;p=emacs.git lisp/progmodes/csharp-mode.el: Improve string-interpolation Correctly fontify expressions inside string-interpolations. (Bug#75580) (cherry picked from commit 535eec814484c437443051e0b6d2d654eef9b7e0) --- diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el index 9d19456179b..b26ce4e34a5 100644 --- a/lisp/progmodes/csharp-mode.el +++ b/lisp/progmodes/csharp-mode.el @@ -736,6 +736,12 @@ compilation and evaluation time conflicts." (treesit-query-compile 'c-sharp "(interpolated_string_text)" t) t)) +(defun csharp-ts-mode--test-string-content () + "Return non-nil if (interpolated_string_text) is in the grammar." + (ignore-errors + (treesit-query-compile 'c-sharp "(string_content)" t) + t)) + (defun csharp-ts-mode--test-type-constraint () "Return non-nil if (type_constraint) is in the grammar." (ignore-errors @@ -830,10 +836,12 @@ compilation and evaluation time conflicts." (boolean_literal) @font-lock-constant-face) :language 'c-sharp - :override t :feature 'string `([(string_literal) (verbatim_string_literal) + ,@ (when (csharp-ts-mode--test-string-content) + '((string_content) + "\"")) ,@(if (csharp-ts-mode--test-interpolated-string-text) '((interpolated_string_text) (interpolated_verbatim_string_text)