@@ -3590,7 +3590,7 @@ function ble/complete/progcomp/.filter-and-split-compgen {
3590
3590
return 0
3591
3591
} 2> /dev/null
3592
3592
3593
- function ble/complete/progcomp/. cobraV2.patch {
3593
+ function ble/complete/progcomp/patch: cobraV2/extract_activeHelp .patch {
3594
3594
local cobra_version=$1
3595
3595
if (( cobra_version< 10500 )) ; then
3596
3596
local -a completions
@@ -3628,6 +3628,21 @@ function ble/complete/progcomp/.cobraV2.patch {
3628
3628
fi
3629
3629
}
3630
3630
3631
+ function ble/complete/progcomp/patch:cobraV2/get_completion_results.advice {
3632
+ local -a orig_words
3633
+ orig_words=(" ${words[@]} " )
3634
+ local -a words
3635
+ words=(ble/complete/progcomp/patch:cobraV2/get_completion_results.invoke " ${orig_words[@]: 1} " )
3636
+ ble/function#advice/do
3637
+ }
3638
+ function ble/complete/progcomp/patch:cobraV2/get_completion_results.invoke {
3639
+ local -a invoke_args; invoke_args=(" $@ " )
3640
+ local invoke_command=" ${orig_words[0]} \"\$ {invoke_args[@]}\" "
3641
+ ble/util/conditional-sync \
3642
+ ' builtin eval -- "$invoke_command"' \
3643
+ " ! ble/complete/check-cancel <&$_ble_util_fd_stdin " 128 progressive-weight:killall
3644
+ }
3645
+
3631
3646
# # @fn ble/complete/progcomp/.compgen opts
3632
3647
# #
3633
3648
# # @param[in] opts
@@ -3735,7 +3750,18 @@ function ble/complete/progcomp/.compgen {
3735
3750
if ble/is-function " __${comp_func# __start_} _extract_activeHelp" ; then
3736
3751
cobra_version=10500 # v1.5.0 (Release 2022-06-21)
3737
3752
fi
3738
- ble/function#advice around " $target " " ble/complete/progcomp/.cobraV2.patch $cobra_version "
3753
+ ble/function#advice around " $target " " ble/complete/progcomp/patch:cobraV2/extract_activeHelp.patch $cobra_version "
3754
+ fi
3755
+
3756
+ # https://github.com/akinomyoga/ble.sh/issues/353#issuecomment-1813801048
3757
+ # Note: Some programs can be slow to generate completions for internet
3758
+ # access or another reason. Since the go programs called by cobraV2
3759
+ # completions are supposed to be an independent executable file (without
3760
+ # being shell functions), we can safely call them inside a subshell for
3761
+ # ble/util/conditional-sync.
3762
+ local target=__${comp_func# __start_} _get_completion_results
3763
+ if ble/is-function " $target " ; then
3764
+ ble/function#advice around " $target " ble/complete/progcomp/patch:cobraV2/get_completion_results.advice
3739
3765
fi
3740
3766
fi
3741
3767
0 commit comments