File tree 1 file changed +17
-5
lines changed
1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -132,12 +132,24 @@ define-command -hidden go-indent-on-closing-curly-brace %[
132
132
try %[ execute-keys -itersel -draft <a-h><a-k>^\h+\}$<ret> hms\A|.\z<ret> 1 <a-&> ]
133
133
]
134
134
135
- define-command -hidden go-insert-comment-on-new-line %[
136
- evaluate-commands -no -hooks -draft -itersel %[
137
- # copy // comments prefix and following white spaces
138
- try %{ execute-keys -draft <semicolon> <c-s>kx s ^\h*\K/{2 ,}\h* <ret> y<c-o>P<esc> }
135
+ define-command -hidden go-insert-comment-on-new-line %[ evaluate-commands -itersel -draft %[
136
+ execute-keys <semicolon>
137
+ try %[
138
+ evaluate-commands -draft -save-regs ' /"' %[
139
+ # copy the commenting prefix
140
+ execute-keys -save-regs ' ' k x1s^\h*(//+\h*)<ret> y
141
+ try %[
142
+ # if the previous comment isn't empty, create a new one
143
+ execute-keys x<a-K>^\h*//+\h*$<ret> jxs^\h*<ret> P
144
+ ] catch %[
145
+ # if there is no text in the previous comment, remove it completely
146
+ execute-keys d
147
+ ]
148
+ ]
149
+ # trim trailing whitespace on the previous line
150
+ try %[ execute-keys -draft k x s\h+$<ret> d ]
139
151
]
140
- ]
152
+ ] ]
141
153
142
154
define-command -hidden go-insert-closing-delimiter-on-new-line %[
143
155
evaluate-commands -no -hooks -draft -itersel %[
You can’t perform that action at this time.
0 commit comments