Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Deprioritise completing for environment directories
Browse files Browse the repository at this point in the history
Only complete for directories to "activate" if the current stem includes
a slash.
  • Loading branch information
tartansandal committed Jul 20, 2022
1 parent 1f1d837 commit 67c4686
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 6 additions & 2 deletions conda
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,12 @@ _comp_conda()
word_list=$(__comp_conda_env_commands 2>/dev/null)
;;
activate)
_filedir -d # environment directories
word_list=$(__comp_conda_envs 2>/dev/null)
if [[ $cur == */* ]]
then
_filedir -d # environment directories
else
word_list=$(__comp_conda_envs 2>/dev/null)
fi
;;
remove|uninstall|upgrade|update)
word_list=$(__comp_conda_packages 2>/dev/null)
Expand Down
9 changes: 8 additions & 1 deletion tests/test_conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,16 @@ def test_sub_comands(self, completion):
]

@pytest.mark.complete("conda activate ")
def test_environments(self, completion):
def test_activate_environment(self, completion):
assert completion
assert 'conda-bash-comp-testing' in completion
assert 'fixture/' not in completion

@pytest.mark.complete("conda activate ../")
def test_activate_path(self, completion):
assert completion
assert 'conda-bash-comp-testing' not in completion
assert 'fixture/' in completion

@pytest.mark.complete("conda env create --")
def test_sub_comand_options(self, completion):
Expand Down

0 comments on commit 67c4686

Please sign in to comment.