From f78cd6daf88540792c342ac3ee2979aaeb2ddd1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kruszewski?= Date: Fri, 18 Sep 2020 15:06:23 +0200 Subject: [PATCH] Improve '}' auto inserting for go language. Adding "} else if ... {" was not correctly handled. --- rc/filetype/go.kak | 4 ++-- test/indent/go/deindent-generic-closing-brace/in | 6 ++++++ test/indent/go/deindent-generic-closing-brace/out | 7 +++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/rc/filetype/go.kak b/rc/filetype/go.kak index e9d98fe0..4c9ad7ee 100644 --- a/rc/filetype/go.kak +++ b/rc/filetype/go.kak @@ -134,7 +134,7 @@ define-command -hidden go-insert-on-new-line %[ try %[ execute-keys -draft ks^\h+"xy ] catch %[ reg x '' ] try %[ # Validate previous line and that it is not closed yet. - execute-keys -draft k ^x.*\{\h*\(?\h*$ J}iJ ^x(\)?\h*\})$ + execute-keys -draft k ^x.*\{\h*\(?\h*$ j}iJ ^x\)?\h*\} # Insert closing '}'. execute-keys -draft ox} # Delete trailing '}' on the line below the '{'. @@ -148,7 +148,7 @@ define-command -hidden go-insert-on-new-line %[ try %[ execute-keys -draft ks^\h+"xy ] catch %[ reg x '' ] try %[ # Validate previous line and that it is not closed yet. - execute-keys -draft k ^x.*\(\h*$ J}iJ ^x(\)\h*\}?)$ + execute-keys -draft k ^x.*\(\h*$ J}iJ ^x\) # Insert closing ')'. execute-keys -draft ox) # Delete trailing ')' on the line below the '('. diff --git a/test/indent/go/deindent-generic-closing-brace/in b/test/indent/go/deindent-generic-closing-brace/in index ef741602..b360ff42 100644 --- a/test/indent/go/deindent-generic-closing-brace/in +++ b/test/indent/go/deindent-generic-closing-brace/in @@ -41,3 +41,9 @@ 12 {( bar()%( ))} + +13 +a := []int{ + someFunction(%( ) + ), +} diff --git a/test/indent/go/deindent-generic-closing-brace/out b/test/indent/go/deindent-generic-closing-brace/out index e3aaa065..26d936fe 100644 --- a/test/indent/go/deindent-generic-closing-brace/out +++ b/test/indent/go/deindent-generic-closing-brace/out @@ -56,3 +56,10 @@ {( bar() )} + +13 +a := []int{ + someFunction( + + ), +}