From 3d8811b55501f37b6c203e2aba1920f62bdf97d6 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sun, 18 Dec 2022 03:03:57 +0900 Subject: [PATCH] fix(make): deactivate the display-only mode 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: https://github.com/scop/bash-completion/issues/544 https://github.com/scop/bash-completion/pull/546 --- completions/make | 17 ++++++++++++----- test/t/test_make.py | 6 +++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/completions/make b/completions/make index 6f66b17eb35..cf379c5e641 100644 --- a/completions/make +++ b/completions/make @@ -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 \ diff --git a/test/t/test_make.py b/test/t/test_make.py index 74efb4a9a35..0fc630b30bd 100644 --- a/test/t/test_make.py +++ b/test/t/test_make.py @@ -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") @@ -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) @@ -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")