Skip to content

Commit

Permalink
Fix completion in zsh special contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
evanunderscore committed Nov 25, 2023
1 parent b6e38aa commit 1f6e661
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 4 additions & 4 deletions argcomplete/bash_completion.d/_python-argcomplete
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ _python_argcomplete_global() {
req_argv=( "" "${COMP_WORDS[@]:1}" )
__python_argcomplete_expand_tilde_by_ref executable
else
if [[ "$service" != "-default-" ]]; then
return
fi
executable="${words[1]}"
req_argv=( "${words[@]:1}" )
fi
Expand Down Expand Up @@ -240,5 +237,8 @@ if [[ -z "${ZSH_VERSION-}" ]]; then
complete -o default -o bashdefault -D -F _python_argcomplete_global
else
autoload is-at-least
compdef _python_argcomplete_global -P '*'
# Replace only the default completer (_default).
# There are many other special contexts we don't want to override.
# https://zsh.sourceforge.io/Doc/Release/Completion-System.html
compdef _python_argcomplete_global -default-
fi
9 changes: 9 additions & 0 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,15 @@ def repl_provider(self):
class TestBashZshGlobalBase(TestBashZshBase):
install_cmd = 'eval "$(activate-global-python-argcomplete --dest=-)"'

def test_redirection_completion(self):
with TempDir(prefix="test_dir_py", dir="."):
self.sh.run_command("cd " + os.getcwd())
self.sh.run_command("echo failure > ./foo.txt")
self.sh.run_command("echo success > ./foo.\t")
with open("foo.txt") as f:
msg = f.read()
self.assertEqual(msg, "success\n")

def test_python_completion(self):
self.sh.run_command("cd " + TEST_DIR)
self.assertEqual(self.sh.run_command("python3 ./prog basic f\t"), "foo\r\n")
Expand Down

0 comments on commit 1f6e661

Please sign in to comment.