Skip to content

Commit

Permalink
edit: work around the wrong job information of Bash in trap handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed May 18, 2021
1 parent 1b00fd2 commit d40847f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
4 changes: 4 additions & 0 deletions src/edit.sh
Expand Up @@ -1189,12 +1189,14 @@ function ble-edit/attach/TRAPWINCH {
if ((_ble_edit_attached)); then
if [[ ! $_ble_textarea_invalidated && $_ble_term_state == internal ]]; then
_ble_textmap_pos=()
ble/util/joblist.check
ble-edit/bind/stdout.on
ble-edit/info/hide
ble/util/buffer "$_ble_term_ed"
ble-edit/info/reveal
ble/textarea#redraw
ble-edit/bind/stdout.off
ble/util/joblist.check ignore-volatile-jobs
fi
fi
}
Expand Down Expand Up @@ -6611,10 +6613,12 @@ function ble/builtin/read/.setup-textarea {
_ble_highlight_layer__list=(plain region overwrite_mode disabled)
}
function ble/builtin/read/TRAPWINCH {
ble/util/joblist.check
local IFS=$_ble_term_IFS
_ble_textmap_pos=()
ble/util/buffer "$_ble_term_ed"
ble/textarea#redraw
ble/util/joblist.check ignore-volatile-jobs
}
function ble/builtin/read/.loop {
set +m # ジョブ管理を無効にする
Expand Down
25 changes: 15 additions & 10 deletions src/util.sh
Expand Up @@ -1732,9 +1732,12 @@ function ble/urange#shift {
}

#------------------------------------------------------------------------------
## 関数 ble/util/joblist
## 関数 ble/util/joblist opts
## 現在のジョブ一覧を取得すると共に、ジョブ状態の変化を調べる。
##
## @param[in] opts
## ignore-volatile-jobs
##
## @var[in,out] _ble_util_joblist_events
## @var[out] joblist ジョブ一覧を格納する配列
## @var[in,out] _ble_util_joblist_jobs 内部使用
Expand All @@ -1750,7 +1753,7 @@ _ble_util_joblist_jobs=
_ble_util_joblist_list=()
_ble_util_joblist_events=()
function ble/util/joblist {
local jobs0
local opts=$1 jobs0
ble/util/assign jobs0 'jobs'
if [[ $jobs0 == "$_ble_util_joblist_jobs" ]]; then
# 前回の呼び出し結果と同じならば状態変化はないものとして良い。終了・強制終
Expand Down Expand Up @@ -1796,14 +1799,16 @@ function ble/util/joblist {
ble/util/joblist.split _ble_util_joblist_list "${lines[@]}"

# check removed jobs through list -> _ble_util_joblist_list.
for ijob in "${!list[@]}"; do
local job0=${list[ijob]}
if [[ $job0 && ! ${_ble_util_joblist_list[ijob]} ]]; then
if [[ $job0 != *'__ble_suppress_joblist__'* ]]; then
ble/array#push _ble_util_joblist_events "$job0"
if [[ :$opts: != *:ignore-volatile-jobs:* ]]; then
for ijob in "${!list[@]}"; do
local job0=${list[ijob]}
if [[ $job0 && ! ${_ble_util_joblist_list[ijob]} ]]; then
if [[ $job0 != *'__ble_suppress_joblist__'* ]]; then
ble/array#push _ble_util_joblist_events "$job0"
fi
fi
fi
done
done
fi
else
for ijob in "${!list[@]}"; do
[[ ${list[ijob]} ]] &&
Expand All @@ -1827,7 +1832,7 @@ function ble/util/joblist.split {
## 内部的に jobs を呼び出す直前に、ジョブ状態変化を取り逃がさない為に明示的に呼び出します。
function ble/util/joblist.check {
local joblist
ble/util/joblist
ble/util/joblist "$@"
}
## 関数 ble/util/joblist.has-events
## 未出力のジョブ状態変化の記録があるかを確認します。
Expand Down

0 comments on commit d40847f

Please sign in to comment.