Merge pull request #2610 from xonsh/trail

fixed trailing bash whitespace completion issue
This commit is contained in:
Morten Enemark Lund 2018-04-09 21:46:29 +02:00 committed by GitHub
commit bd5be59f00
Failed to generate hash of commit
2 changed files with 27 additions and 1 deletions

15
news/trail.rst Normal file
View file

@ -0,0 +1,15 @@
**Added:** None
**Changed:** None
**Deprecated:** None
**Removed:** None
**Fixed:**
* Commands like ``git c`` would complete to ``git 'checkout '`` because git adds an extra space
to the end of the completion, which was being captured in the completion. Xonsh now fixes the git issue
while retaining all whitespace when there is other internal whitespace.
**Security:** None

View file

@ -239,7 +239,18 @@ COMP_COUNT={end}
COMP_CWORD={n}
$_func {cmd} {prefix} {prev}
for ((i=0;i<${{#COMPREPLY[*]}};i++)) do echo "${{COMPREPLY[i]}}"; done
# print out completions, right-stripped if they contain no internal spaces
shopt -s extglob
for ((i=0;i<${{#COMPREPLY[*]}};i++))
do
no_spaces="${{COMPREPLY[i]//[[:space:]]}}"
no_trailing_spaces="${{COMPREPLY[i]%%+([[:space:]])}}"
if [[ "$no_spaces" == "$no_trailing_spaces" ]]; then
echo "$no_trailing_spaces"
else
echo "${{COMPREPLY[i]}}"
fi
done
"""