[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#61238: [PATCH] Fix go-ts-mode type switch and select case blocks ind
From: |
Theodor Thornhill |
Subject: |
bug#61238: [PATCH] Fix go-ts-mode type switch and select case blocks indentation |
Date: |
Sat, 04 Feb 2023 09:24:08 +0100 |
Hey there, Davide, and thanks for the clear bug-report!
This looks good to me, but before I install, Maybe you can also add a
test for this, similar to the ones in c-ts-mode-tests.el?
Also, just checking - is fsf assignment needed for this change? Maybe
you've done it already, if so, forgive my ignorance :-)
Theo
> Tags: patch
>
> This patch add indentation for Go type switch and select case blocks.
>
> Current behavior
> ```
> var x any
> switch x.(type) {
> case int:
> println(x)
> }
>
> var c chan int
> select {
> case x := <-c:
> println(x)
> }
> ```
>
> Correct behavior
> ```
> var x any
> switch x.(type) {
> case int:
> println(x)
> }
>
> var c chan int
> select {
> case x := <-c:
> println(x)
> }
> ```
>
>
>>From b4d6ed0dcb2536d6345e38edd7fc3ae1661d99b7 Mon Sep 17 00:00:00 2001
> From: Davide Masserut <dm@mssdvd.com>
> Date: Thu, 2 Feb 2023 21:00:02 +0100
> Subject: [PATCH] Fix go-ts-mode type switch and select case blocks indentation
>
> * lisp/progmodes/go-ts-mode.el (go-ts-mode--indent-rules): Add
> indentation for type switch and select case blocks
> ---
> lisp/progmodes/go-ts-mode.el | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el
> index 5f3e1ea3e68..0270b92445d 100644
> --- a/lisp/progmodes/go-ts-mode.el
> +++ b/lisp/progmodes/go-ts-mode.el
> @@ -72,6 +72,7 @@ go-ts-mode--indent-rules
> ((node-is "labeled_statement") no-indent)
> ((parent-is "argument_list") parent-bol go-ts-mode-indent-offset)
> ((parent-is "block") parent-bol go-ts-mode-indent-offset)
> + ((parent-is "communication_case") parent-bol go-ts-mode-indent-offset)
> ((parent-is "const_declaration") parent-bol go-ts-mode-indent-offset)
> ((parent-is "default_case") parent-bol go-ts-mode-indent-offset)
> ((parent-is "expression_case") parent-bol go-ts-mode-indent-offset)
> @@ -82,6 +83,7 @@ go-ts-mode--indent-rules
> ((parent-is "labeled_statement") parent-bol go-ts-mode-indent-offset)
> ((parent-is "literal_value") parent-bol go-ts-mode-indent-offset)
> ((parent-is "parameter_list") parent-bol go-ts-mode-indent-offset)
> + ((parent-is "type_case") parent-bol go-ts-mode-indent-offset)
> ((parent-is "type_spec") parent-bol go-ts-mode-indent-offset)
> ((parent-is "var_declaration") parent-bol go-ts-mode-indent-offset)
> (no-node parent-bol 0)))