Skip to content

Commit 3cdb549

Browse files
authored
fix(scp): fix a bug that -F<prefix>[TAB] did not complete at all (#1396)
This was because the filtering by a modified `cur` is performed after prefixing "-F". Since we generate the filenames starting with "$cur", we do not need to further filter the results with `cur`. We disable the filtering by specifying the `-R` flag to `_comp_compgen`.
1 parent 07e2934 commit 3cdb549

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

completions/ssh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,13 +547,13 @@ _comp_xfunc_scp_compgen_local_files()
547547
local files
548548
_comp_expand_glob files '"$cur"*' || return 0
549549
if [[ $_dirsonly ]]; then
550-
_comp_compgen -U files split -l -- "$(
550+
_comp_compgen -RU files split -l -- "$(
551551
command ls -aF1dL "${files[@]}" 2>/dev/null |
552552
command sed -e "s/$_comp_cmd_scp__path_esc/\\\\&/g" \
553553
-e '/[^\/]$/d' -e "s/^/${1-}/"
554554
)"
555555
else
556-
_comp_compgen -U files split -l -- "$(
556+
_comp_compgen -RU files split -l -- "$(
557557
command ls -aF1dL "${files[@]}" 2>/dev/null |
558558
command sed -e "s/$_comp_cmd_scp__path_esc/\\\\&/g" \
559559
-e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' -e "s/^/${1-}/"

test/t/test_scp.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ def test_capital_f_without_space(self, completion):
5858
"option requires an argument -- F" in x for x in completion
5959
)
6060

61+
@pytest.mark.complete("scp -Fconf", cwd="scp")
62+
def test_capital_f_without_space_2(self, completion):
63+
assert completion == "ig"
64+
65+
@pytest.mark.complete("scp -Fbi", cwd="scp")
66+
def test_capital_f_without_space_3(self, completion):
67+
assert completion == "n/"
68+
6169
@pytest.fixture(scope="class")
6270
def live_pwd(self, bash):
6371
try:

0 commit comments

Comments
 (0)