Skip to content

Commit

Permalink
Merge pull request #1021 from zachlewis/bugfix/py3_completion
Browse files Browse the repository at this point in the history
Fix tab-completion behavior for rez deployments installed with python3
  • Loading branch information
nerdvegas authored Feb 23, 2021
2 parents 555d177 + efb6157 commit 2221335
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/rez/cli/_complete_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os.path
from fnmatch import fnmatch
from rez.vendor.argcomplete import CompletionFinder, default_validator, \
sys_encoding, split_line, debug
sys_encoding, split_line, debug, USING_PYTHON2


class RezCompletionFinder(CompletionFinder):
Expand All @@ -12,9 +12,12 @@ def __init__(self, parser, comp_line, comp_point):
self.exclude = None
self.validator = default_validator
self.wordbreaks = " \t\"'@><=;|&(:" # TODO: might need to be configurable/OS specific

comp_point = len(comp_line[:comp_point].decode(sys_encoding))
comp_line = comp_line.decode(sys_encoding)

if USING_PYTHON2:
comp_line = comp_line.decode(sys_encoding)
comp_point = len(comp_line[:comp_point].decode(sys_encoding))
else:
comp_point = len(comp_line.encode(sys_encoding)[:comp_point].decode(sys_encoding))

cword_prequote, cword_prefix, cword_suffix, comp_words, \
first_colon_pos = split_line(comp_line, comp_point)
Expand Down
1 change: 1 addition & 0 deletions src/rez/cli/complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def _pop_arg(l, p):
comp_line=comp_line,
comp_point=comp_point)
words = completer.completions
words = [w.decode() if hasattr(w, 'decode') else w for w in words]
print(' '.join(words))


Expand Down

0 comments on commit 2221335

Please sign in to comment.