File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,8 @@ _function()
88 if (( cword == 1 )) ; then
99 COMPREPLY=($( compgen -A function -- " $cur " ))
1010 else
11- COMPREPLY=(" () $( type -- ${words[1]} | command sed -e 1,2d) " )
11+ local funcdef=$( type -- " ${words[1]} " 2> /dev/null | command sed -e 1,2d)
12+ COMPREPLY=(" ()${funcdef: + $funcdef } " )
1213 fi
1314} &&
1415 complete -F _function function
Original file line number Diff line number Diff line change 11import pytest
22
3+ from conftest import assert_bash_exec , assert_complete
34
5+
6+ @pytest .mark .bashcomp (ignore_env = r"^\+declare -f fn$" )
47class TestFunction :
58 @pytest .mark .complete ("function _parse_" )
69 def test_1 (self , completion ):
710 assert completion
11+
12+ @pytest .mark .complete ("function non_existent_function " )
13+ def test_2 (self , completion ):
14+ assert completion == "()"
15+
16+ def test_3 (self , bash ):
17+ assert_bash_exec (bash , "fn() { echo; }" )
18+ completion = assert_complete (bash , "function fn " )
19+ assert completion == "() { ^J echo^J}"
You can’t perform that action at this time.
0 commit comments