Skip to content

Commit

Permalink
fix(make): deactivate the display-only mode
Browse files Browse the repository at this point in the history
In the display-only mode where COMP_TYPE=9, 37, or 42, only a part of
the completion is stored in COMPREPLY for displaying purposes.  For
example, "xyz" is stored in COMPREPLY when "abc/xyz" is the candidate
and "abc/" is already inserted.

However, the test framework extracts generated completions using
COMP_TYPE=37 by setting "set show-all-if-ambiguous off", which would
be broken by the display-only mode.  There is no simple way to make it
work with the test framework, and the display-only mode does not seem
to be essential.  For the time being, we deactivate the display-only
mode.  See also discussions in the following links:

#544
#546
  • Loading branch information
akinomyoga committed Dec 19, 2022
1 parent 8d4c394 commit 3d8811b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
17 changes: 12 additions & 5 deletions completions/make
Expand Up @@ -157,12 +157,19 @@ _make()
fi
done

# recognise that possible completions are only going to be displayed
# so only the base name is shown
# recognise that possible completions are only going to be displayed so
# only the base name is shown.
#
# Note: This is currently turned off because the test suite of
# bash-completion conflicts with it; it uses "set show-all-if-ambiguous
# on" (causing COMP_TYPE == 37) to retrieve the action completion
# results, and also the compact form with only the basenames is not
# essentially needed. To re-enable it, please uncomment the following
# if-statement.
local mode=--
if ((COMP_TYPE != 9 && COMP_TYPE != 37 && COMP_TYPE != 42)); then
mode=-d # display-only mode
fi
# if ((COMP_TYPE != 9 && COMP_TYPE != 37 && COMP_TYPE != 42)); then
# mode=-d # display-only mode
# fi

local IFS=$' \t\n' script=$(_make_target_extract_script $mode "$cur")
COMPREPLY=($(LC_ALL=C \
Expand Down
6 changes: 3 additions & 3 deletions test/t/test_make.py
Expand Up @@ -18,7 +18,7 @@ def test_2(self, bash, completion):

@pytest.mark.complete("make .cache/", cwd="make", require_cmd=True)
def test_3(self, bash, completion):
assert completion == "1 2".split()
assert completion == ".cache/1 .cache/2".split()
os.remove(f"{bash.cwd}/make/extra_makefile")

@pytest.mark.complete("make ", cwd="shared/empty_dir")
Expand All @@ -36,7 +36,7 @@ def test_6(self, bash, completion):

@pytest.mark.complete("make .cache/.", cwd="make", require_cmd=True)
def test_7(self, bash, completion):
assert completion == ".1 .2".split()
assert completion == ".cache/.1 .cache/.2".split()
os.remove(f"{bash.cwd}/make/extra_makefile")

@pytest.mark.complete("make -C make ", require_cmd=True)
Expand All @@ -61,7 +61,7 @@ def test_github_issue_544_2(self, bash):

def test_github_issue_544_3(self, bash):
completion = assert_complete(bash, "make 123/")
assert completion == ["xaa", "xbb"]
assert completion == ["123/xaa", "123/xbb"]

def test_github_issue_544_4(self, bash):
completion = assert_complete(bash, "make 123/xa")
Expand Down

0 comments on commit 3d8811b

Please sign in to comment.