[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#70345: [PATCH] 29.1.50; csharp-ts-mode indentation of if statements
From: |
Jacob Leeming |
Subject: |
bug#70345: [PATCH] 29.1.50; csharp-ts-mode indentation of if statements with single-statement body |
Date: |
Mon, 15 Apr 2024 22:38:00 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Theodor Thornhill <theo@thornhill.no> writes:
>> Hi all,
>>
>
> Hi, Jacob!
>
>>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)
>>
>
> Looks good to me. Are you willing to pack this up with a nice test
> confirming the behavior?
>
> All the best,
> Theo
I'm willing, where can I find other tests for csharp-ts-mode? Had a
quick look round the emacs repo but could not find any.
Cheers,
Jacob
- bug#70345: [PATCH] 29.1.50; csharp-ts-mode indentation of if statements with single-statement body, Jacob Leeming, 2024/04/11
- bug#70345: [PATCH] 29.1.50; csharp-ts-mode indentation of if statements with single-statement body, Eli Zaretskii, 2024/04/12
- bug#70345: [PATCH] 29.1.50; csharp-ts-mode indentation of if statements with single-statement body, Yuan Fu, 2024/04/14
- bug#70345: [PATCH] 29.1.50; csharp-ts-mode indentation of if statements with single-statement body, Theodor Thornhill, 2024/04/15
- bug#70345: [PATCH] 29.1.50; csharp-ts-mode indentation of if statements with single-statement body,
Jacob Leeming <=
- bug#70345: [PATCH] 29.1.50; csharp-ts-mode indentation of if statements with single-statement body, Jacob Leeming, 2024/04/22
- bug#70345: [PATCH] 29.1.50; csharp-ts-mode indentation of if statements with single-statement body, john muhl, 2024/04/27
- bug#70345: [PATCH] 29.1.50; csharp-ts-mode indentation of if statements with single-statement body, Eli Zaretskii, 2024/04/27
- bug#70345: [PATCH] 29.1.50; csharp-ts-mode indentation of if statements with single-statement body, john muhl, 2024/04/27
- bug#70345: [PATCH] 29.1.50; csharp-ts-mode indentation of if statements with single-statement body, Eli Zaretskii, 2024/04/27