Improve '}' auto inserting for go language.
Adding "} else if ... {" was not correctly handled.
This commit is contained in:
parent
dbd7e4da79
commit
f78cd6daf8
|
@ -134,7 +134,7 @@ define-command -hidden go-insert-on-new-line %[
|
|||
try %[ execute-keys -draft k<a-x>s^\h+<ret>"xy ] catch %[ reg x '' ]
|
||||
try %[
|
||||
# Validate previous line and that it is not closed yet.
|
||||
execute-keys -draft k<a-x> <a-k>^<c-r>x.*\{\h*\(?\h*$<ret> J}iJ<a-x> <a-K>^<c-r>x(\)?\h*\})$<ret>
|
||||
execute-keys -draft k<a-x> <a-k>^<c-r>x.*\{\h*\(?\h*$<ret> j}iJ<a-x> <a-K>^<c-r>x\)?\h*\}<ret>
|
||||
# Insert closing '}'.
|
||||
execute-keys -draft o<c-r>x}<esc>
|
||||
# Delete trailing '}' on the line below the '{'.
|
||||
|
@ -148,7 +148,7 @@ define-command -hidden go-insert-on-new-line %[
|
|||
try %[ execute-keys -draft k<a-x>s^\h+<ret>"xy ] catch %[ reg x '' ]
|
||||
try %[
|
||||
# Validate previous line and that it is not closed yet.
|
||||
execute-keys -draft k<a-x> <a-k>^<c-r>x.*\(\h*$<ret> J}iJ<a-x> <a-K>^<c-r>x(\)\h*\}?)$<ret>
|
||||
execute-keys -draft k<a-x> <a-k>^<c-r>x.*\(\h*$<ret> J}iJ<a-x> <a-K>^<c-r>x\)<ret>
|
||||
# Insert closing ')'.
|
||||
execute-keys -draft o<c-r>x)<esc>
|
||||
# Delete trailing ')' on the line below the '('.
|
||||
|
|
|
@ -41,3 +41,9 @@
|
|||
12
|
||||
{(
|
||||
bar()%( ))}
|
||||
|
||||
13
|
||||
a := []int{
|
||||
someFunction(%( )
|
||||
),
|
||||
}
|
||||
|
|
|
@ -56,3 +56,10 @@
|
|||
{(
|
||||
bar()
|
||||
)}
|
||||
|
||||
13
|
||||
a := []int{
|
||||
someFunction(
|
||||
|
||||
),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user