complete: Don't change to _GO_ROOTDIR
#124
Merged
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.
Closes #123. Tab completion will no longer change the working directory to
_GO_ROOTDIR
, the tradeoff being:-o nospace
now instead of-o filenames
../go
framework must add traling slashes to directory name completions, as well as add a space when returning a single completion (unless it ends with a/
).To this last point, per @jeffkole, having longer completion paths seems less surprising and annoying than having the working directory change. I'd originally thought it would mean completing absolute paths, but it turns out that wasn't necessary after all. In fact, the completed path on the command line stays the same length as before this change; it's just the values displayed when multiple matches exist that are longer.
The core of the
@go.compgen
solution fromlib/complete
is pretty straightforward, but since./go complete
will now add trailing slashes for directories, and trailing spaces when there is only one match, a lot of tests needed very minor updates.Another bonus of this solution: Previously I named the test directory
tests
because tab-completing thetest
command would cause the previous implementation to add a slash if atest
directory existed. Since we're not setting-o filenames
, and are now filtering filename completions through@go.compgen
, this should not be an issue for other projects. The "doesn't add trailing slashes when not called with -d or -f" test case fromtests/complete/compgen.bats
covers this.While touching all these test files, I decided to apply a few other convenient updates, namely:
test_filter
tosetup
IFS=$'\n'
with the updatedassert_{success,failure}
that accept multiple arguments to check for line-by-line equality