Subject: bug#70345: closed (Re: bug#70345: [PATCH] 29.1.50; csharp-ts-mode indentation of if statements with single-statement body)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 25 Apr 2024 16:05:04 +0000

Your bug report

#70345: [PATCH] 29.1.50; csharp-ts-mode indentation of if statements with single-statement body

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
70345: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=70345
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#70345: [PATCH] 29.1.50; csharp-ts-mode indentation of if statements with single-statement body
From: Eli Zaretskii <[email-masked]>
To: Jacob Leeming <[email-masked]>
Cc: [email-masked], [email-masked], [email-masked]
Date: Thu, 25 Apr 2024 19:04:14 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> Cc: [email-masked], Jacob Leeming <[email-masked]>
> From: Jacob Leeming <[email-masked]>
> Date: Mon, 22 Apr 2024 09:50:23 +0100
> 
> > Looks good to me. Are you willing to pack this up with a nice test
> > confirming the behavior?
> >
> > All the best,
> > Theo
> 
> Thanks all,
> 
> Discovered we had a similar issue for else blocks. Wrote a test that
> covers both cases.
> 
> See the attached diff which contains my changes to the indent rules and
> the test.

Thanks, I installed this on the emacs-29 branch.  (The test you added
should have been added to csharp-mode-tests.el, since our test files
follow the names of the implementation files, and csharp-ts-mode is
implemented in csharp-mode.el.  I fixed that.)

With this changeset you have exhausted the amount of changes that we
can accept from you without copyright assignment.  Would you like to
start the paperwork of assigning the copyright at this time, so that
we could accept your contributions in the future without limitations?
If yes, I will send you the form to fill and the instructions to send
the form.

I'm closing this bug.

Subject: [PATCH] 29.1.50; csharp-ts-mode indentation of if statements with single-statement body
From: Jacob Leeming <[email-masked]>
To: [email-masked]
Date: Thu, 11 Apr 2024 21:32:02 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi all,

>From emacs -Q:

Evaluate this elisp to set up treesitter for csharp:

(setq treesit-language-source-alist '((c-sharp
"https://github.com/tree-sitter/tree-sitter-c-sharp" "master" "src"))
      treesit-load-name-override-list '((c-sharp
"libtree-sitter-csharp" "tree_sitter_c_sharp"))
      major-mode-remap-alist '((csharp-mode . csharp-ts-mode)))

Insert the following text into a csharp-ts-mode buffer:

if (true)
var x = 2;

Try to indent the variable declaration of the function with
indent-for-tab-command. Nothing will happen. I'd expect to see this:

if (true)
    var x = 2;

This issue can be fixed with the following patch:

diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el
index 53c52e6..1a7d535 100644
--- a/lisp/progmodes/csharp-mode.el
+++ b/lisp/progmodes/csharp-mode.el
@@ -678,7 +678,8 @@ csharp-ts-mode--indent-rules
      ((parent-is "binary_expression") parent 0)
      ((parent-is "block") parent-bol csharp-ts-mode-indent-offset)
      ((parent-is "local_function_statement") parent-bol 0)
-     ((parent-is "if_statement") parent-bol 0)
+     ((match "block" "if_statement") parent-bol 0)
+     ((parent-is "if_statement") parent-bol csharp-ts-mode-indent-offset)
      ((parent-is "for_statement") parent-bol 0)
      ((parent-is "for_each_statement") parent-bol 0)
      ((parent-is "while_statement") parent-bol 0)

Cheers,
Jacob