Skip to content

Commit 595f905

Browse files
committed
complete: use conditional-sync for cobraV2 completions
1 parent ba2b886 commit 595f905

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

docs/ChangeLog.md

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
- decode: work around `convert-meta on` in bash >= 5.2 with broken locale (reported by 3ximus) `#D2069` 226f9718
5454
- canvas: adjust GraphemeClusterBreak of hankaku-kana voiced marks `#D2077` 31d168cc
5555
- canvas: update tables and grapheme clusters for Unicode 15.1.0 `#D2078` 503bb38b 9d84b424 9d84b424
56+
- complete: use conditional-sync for cobraV2 completions (reported by sebhoss) `#D2084` xxxxxxxx
5657

5758
## Contrib
5859

lib/core-complete.sh

+28-2
Original file line numberDiff line numberDiff line change
@@ -3590,7 +3590,7 @@ function ble/complete/progcomp/.filter-and-split-compgen {
35903590
return 0
35913591
} 2>/dev/null
35923592

3593-
function ble/complete/progcomp/.cobraV2.patch {
3593+
function ble/complete/progcomp/patch:cobraV2/extract_activeHelp.patch {
35943594
local cobra_version=$1
35953595
if ((cobra_version<10500)); then
35963596
local -a completions
@@ -3628,6 +3628,21 @@ function ble/complete/progcomp/.cobraV2.patch {
36283628
fi
36293629
}
36303630

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+
36313646
## @fn ble/complete/progcomp/.compgen opts
36323647
##
36333648
## @param[in] opts
@@ -3735,7 +3750,18 @@ function ble/complete/progcomp/.compgen {
37353750
if ble/is-function "__${comp_func#__start_}_extract_activeHelp"; then
37363751
cobra_version=10500 # v1.5.0 (Release 2022-06-21)
37373752
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
37393765
fi
37403766
fi
37413767

note.txt

+15
Original file line numberDiff line numberDiff line change
@@ -7086,6 +7086,21 @@ bash_tips
70867086
Done (実装ログ)
70877087
-------------------------------------------------------------------------------
70887088

7089+
2023-11-16
7090+
7091+
* completino(kubectl): 補完で hang する。timeout は 32s ある (reported by sebhoss) [#D2084]
7092+
https://github.com/akinomyoga/ble.sh/issues/353#issuecomment-1811985511
7093+
7094+
提供された補完設定を確認する限りは cobraV2 による補完設定の様である。実際に
7095+
binary を呼んでいる箇所を conditional-sync に置き換えれば十分だろう。binary
7096+
は words[0] を使って読み取っている。基本的には words[0] を置き換えるだけで
7097+
処理を摩り替える事ができるだろう。実装した。
7098+
7099+
動作確認も行った。kubectl に対しては確認していないが gh に対して gh を
7100+
sleep 5 に置き換える事によって遅い時の振る舞いのテストを行った。置き換える
7101+
前はちゃんと動いていて、置き換えた後も補完は動かないが block する事なく入力
7102+
する事ができる。OK
7103+
70897104
2023-11-10
70907105

70917106
* contrib/integration/fzf-git: エラーメッセージが出る (reported by dgudim) [#D2083]

0 commit comments

Comments
 (0)