Bugfix - Job Fails Silently When Path Contains Spaces #2472
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Identification
I noticed that certain commands, such as all of the
GoTest
variants (GoTest
,GoTestCompile
,GoTestFunc
, etc) weren't working for only some of my projects. Interestingly, when they failed, they failed silently, with no logs, messages, or errors.After trying these commands in other projects, some in module mode, some in my GOPATH, etc, I realized that the consistent issue was for paths that had certain characters, such as spaces.
I narrowed the issue down to an over-eager escaping of a file-path in the
go#job#Options
function:vim-go/autoload/go/job.vim
Line 64 in c6273c5
... which was causing the early return due to the condition that intends to squelch error messages for otherwise "virtual" files:
vim-go/autoload/go/job.vim
Lines 286 to 287 in c6273c5
I then noticed that not only was the escaping eager, but it was inconsistent with the later attempt to grab the same path, if one wasn't provided:
vim-go/autoload/go/job.vim
Line 285 in c6273c5
Fix
This PR fixes the over-eager escaping of the file-path of the job directory in
go#job#Options
that caused paths with certain characters and spaces to fail (silently) to be able to execute a job.I also made sure to properly escape the path later on, where it was necessary, as its potentially used in a raw command later on that would require this level of escaping.