Skip to content

Commit 6fa4425

Browse files
authored
Merge pull request #2785 from bhcleek/run/show-command
cmd: show command in :GoRun when g:go_debug includes shell-commands
2 parents ec5a7b1 + ef32ee3 commit 6fa4425

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

autoload/go/cmd.vim

+14-5
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ function! go#cmd#Run(bang, ...) abort
154154

155155
call go#statusline#Update(expand('%:p:h'), l:status)
156156

157-
let l:cmd = "go run "
157+
let l:cmd = ['go', 'run']
158158
let l:tags = go#config#BuildTags()
159159
if len(l:tags) > 0
160-
let l:cmd .= "-tags " . go#util#Shellescape(l:tags) . " "
160+
let l:cmd = l:cmd + ['-tags', l:tags]
161161
endif
162162

163163
if a:0 == 0
@@ -166,15 +166,19 @@ function! go#cmd#Run(bang, ...) abort
166166
let l:files = map(copy(a:000), "expand(v:val)")
167167
endif
168168

169-
let l:cmd = printf('%s%s', l:cmd, go#util#Shelljoin(l:files, 1))
169+
let l:cmd = l:cmd + l:files
170170

171171
let l:cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
172172
let l:dir = getcwd()
173173

174174
if go#util#IsWin()
175175
try
176+
if go#util#HasDebug('shell-commands')
177+
call go#util#EchoInfo('shell command: ' . l:cmd)
178+
endif
179+
176180
execute l:cd . fnameescape(expand("%:p:h"))
177-
exec printf('!%s', l:cmd)
181+
exec printf('!%s', go#util#Shelljoin(l:cmd, 1))
178182
finally
179183
execute l:cd . fnameescape(l:dir)
180184
endtry
@@ -199,7 +203,7 @@ function! go#cmd#Run(bang, ...) abort
199203

200204
" :make expands '%' and '#' wildcards, so they must also be escaped
201205
let l:default_makeprg = &makeprg
202-
let &makeprg = l:cmd
206+
let &makeprg = go#util#Shelljoin(l:cmd, 1)
203207

204208
let l:listtype = go#list#Type("GoRun")
205209

@@ -209,6 +213,11 @@ function! go#cmd#Run(bang, ...) abort
209213
" backup user's errorformat, will be restored once we are finished
210214
let l:old_errorformat = &errorformat
211215
let &errorformat = s:runerrorformat()
216+
217+
if go#util#HasDebug('shell-commands')
218+
call go#util#EchoInfo('shell command: ' . l:cmd)
219+
endif
220+
212221
execute l:cd . fnameescape(expand("%:p:h"))
213222
if l:listtype == "locationlist"
214223
exe 'lmake!'

0 commit comments

Comments
 (0)