GNU bug report logs - #70345
[PATCH] 29.1.50; csharp-ts-mode indentation of if statements with single-statement body

Previous Next

Package: emacs;

Reported by: Jacob Leeming <jacobtophatleeming <at> gmail.com>

Date: Thu, 11 Apr 2024 20:33:03 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Yuan Fu <casouri <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 70345 <at> debbugs.gnu.org, theo <at> thornhill.no, jacobtophatleeming <at> gmail.com
Subject: bug#70345: [PATCH] 29.1.50; csharp-ts-mode indentation of if  statements with single-statement body
Date: Sun, 14 Apr 2024 16:02:50 -0700
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Jacob Leeming <jacobtophatleeming <at> gmail.com>
>> Date: Thu, 11 Apr 2024 21:32:02 +0100
>> 
>> 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)
>
> Theo and Yuan, any comments?

If Theo is too busy I can take a look, but I don’t really know
csharp-ts-mode too well.

Yuan




This bug report was last modified 1 year and 85 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.