From 629bab2a4a946e7c281993d05f6ea19d848e17da Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jostein=20Kj=C3=B8nigsen?= Date: Sat, 1 Feb 2025 22:16:36 +0100 Subject: [PATCH] lisp/progmodes/csharp-mode.el: Improve string-interpolation Correctly fontify expressions inside string-interpolations. (Bug#75580) (cherry picked from commit 535eec814484c437443051e0b6d2d654eef9b7e0) --- lisp/progmodes/csharp-mode.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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) -- 2.39.5