Subject: bug#62399: 30.0.50; eglot + csharp-ts-mode, query pattern is malformed

From: 牟 桐 <[email-masked]>
Date: Thu, 23 Mar 2023 16:19:59 +0000

Thanks, I tried your patch and now it works fine on my computer now.

Hope to see it got merged soon 😉

发件人: Dmitry Gutov<mailto:[email-masked]>
发送时间: 2023年3月23日 15:57
收件人: 牟 桐<mailto:[email-masked]>; [email-masked]<mailto:[email-masked]>; Theodor Thornhill<mailto:[email-masked]>
主题: Re: bug#62399: 回复: bug#62399: 30.0.50; eglot + csharp-ts-mode, query pattern is malformed

On 23/03/2023 08:25, 牟 桐 wrote:
> Ah sorry, here it is:
>
> ``` csharp-ts-mode
> Console.WriteLine("Hello, World!");
> ```
>
> (yes, just one line...)

Thanks! I guess the problem will show up with any file.

And I can repro after installing the c-sharp grammar from master.

> The lsp I’m using is `csharp-ls`, I guess it won’t affect this issue.
>
> But just in case, the way to install `csharp-ls` is
>
>     dotnet tool install csharp-ls -g

A language server was not necessary to reproduce this, but thanks.

This is the patch that worked for me:

diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el
index 47cd13e7fdb..e2df08f4dae 100644
--- a/lisp/progmodes/csharp-mode.el
+++ b/lisp/progmodes/csharp-mode.el
@@ -832,7 +832,7 @@ csharp-ts-mode--font-lock-settings

       (constructor_declaration name: (_) @font-lock-type-face)

-     (method_declaration type: [(identifier) (void_keyword)]
@font-lock-type-face)
+     (method_declaration type: [(identifier) (predefined_type)]
@font-lock-type-face)
       (method_declaration type: (generic_name (identifier)
@font-lock-type-face))
       (method_declaration name: (_) @font-lock-function-name-face)

Looks like a change was made to the grammar fairly recently which made
(void_keyword) not valid in the above context:
https://github.com/tree-sitter/tree-sitter-c-sharp/commit/18a531d4c133d9f1b3796b9bead7681ba3382fb3

Cc'ing the author of that mode for a second opinion. But I guess we'll
need a runtime check just like we added for java-ts-mode recently.