diff --git a/memo/ChangeLog.md b/memo/ChangeLog.md index 4c1b42eb..e40ebd64 100644 --- a/memo/ChangeLog.md +++ b/memo/ChangeLog.md @@ -36,6 +36,7 @@ - prompt: support `bleopt prompt_{{ps1,rps1}{_final,_transient}}` (suggested by Dave-Elec) `#D1366` 06381c9 - prompt: fix a bug that prompt are always re-insntiated for every rendering `#D1374` 0770cda - prompt: fix a bug that rprompt is not cleared when `bleopt prompt_rps1` is reset `#D1377` 1904b1d + - prompt: fix a bug that prompts updated by `PROMPT_COMMAND` are not reflected immediately `#D1426` 0000000 - edit: support Bash 5.1 widgets `#D1368` e747ee3 - color: support `TERM=*-direct` `#D1369` 0d38897 `#D1370` f7dc477 - complete: support `bleopt complete_auto_menu` `#D1373` 77bfabd @@ -81,7 +82,7 @@ - menu: preserve columns with `{forward,backward}-line` `#D1396` 3d5a341 - syntax: rename `ble_debug` to `bleopt syntax_debug` `#D1398` 3cda58b - syntax: change a style of buffer contents in `bleopt syntax_debug` `#D1399` 3cda58b -- complete: change to generate filenames starting from `.` by default `#D1425` 0000000 +- complete: change to generate filenames starting from `.` by default `#D1425` 987436d ## Fix @@ -151,7 +152,7 @@ - complete (`source:file`): fix a bug that tilde expansion candidates are always filtered out `#D1416` 5777d7f - complete: fix a problem of redundant unmatched ambiguous part with tilde expansions in the common prefix `#D1417` 5777d7f - highlight: fix remaininig highlighting of vanishing words `#D1421` `#D1422` 1066653 -- complete: fix a problem that the user setting `dotglob` is changed `#D1425` 0000000 +- complete: fix a problem that the user setting `dotglob` is changed `#D1425` 987436d ## Compatibility diff --git a/note.txt b/note.txt index c4fdaeea..da1f5ab9 100644 --- a/note.txt +++ b/note.txt @@ -3630,6 +3630,16 @@ bash_tips 2020-12-01 + * prompt: PROMPT_COMMAND で変更した PS1 がその場で反映されない (reported by 3ximus) [#D1426] + https://github.com/akinomyoga/ble.sh/issues/72 + + 確認した。これは書き換えミスである。prompt_ps1_final 等の書き換えの時に、 + 更新の必要性があるかどうかの判定を PROMPT_COMMAND よりも前に持ってきたのが行けない。 + + これはどの様に修正したら良いだろうか。PROMPT_COMMAND は更新の必要がある時に + のみ実行したい。或いは :leave: の時にも実行するべきだろうか。leave の時に + PROMPT_COMMAND は実行しなくても良い気がしてきた。うん。その様に変更する。 + * complete: 単語補完で = の右辺の . で始まるファイル名が補完されない [#D1425] https://github.com/akinomyoga/ble.sh/issues/71 diff --git a/src/edit.sh b/src/edit.sh index e47cddcc..ad05923c 100644 --- a/src/edit.sh +++ b/src/edit.sh @@ -817,22 +817,17 @@ function ble/prompt/update/.eval-prompt_command { ## 描画開始点の左の文字コードを指定します。 ## 描画終了点の左の文字コードが分かる場合にそれを返します。 function ble/prompt/update { - local opts=:$1: force= ps1=$_ble_edit_PS1 rps1=$bleopt_prompt_rps1 + local opts=:$1: is_leave_rewrite= if [[ $opts == *:leave:* ]]; then local ps1f=$bleopt_prompt_ps1_final local rps1f=$bleopt_prompt_rps1_final local ps1t=$bleopt_prompt_ps1_transient [[ :$ps1t: == *:trim:* || :$ps1t: == *:same-dir:* && $PWD != $_ble_edit_line_opwd ]] && ps1t= - if [[ $ps1f || $rps1f || $ps1t ]]; then - [[ $ps1f || $ps1t ]] && ps1=$ps1f - [[ $ps1f ]] && rps1=$rps1f - force=1 - ble/textarea#invalidate - fi + [[ $ps1f || $rps1f || $ps1t ]] && is_leave_rewrite= fi local version=$COLUMNS:$_ble_edit_lineno:$_ble_history_count - if [[ ! $force && ${_ble_edit_prompt[0]} == "$version" ]]; then + if [[ ! $is_leave_rewrite && ${_ble_edit_prompt[0]} == "$version" ]]; then ble/prompt/.load return 0 fi @@ -841,12 +836,19 @@ function ble/prompt/update { local cache_d= cache_t= cache_A= cache_T= cache_at= cache_j= cache_wd= # update PS1 - if ble/prompt/update/.has-prompt_command || blehook/has-hook PRECMD; then + if [[ ! $is_leave_rewrite ]] && { ble/prompt/update/.has-prompt_command || blehook/has-hook PRECMD; }; then ble-edit/restore-PS1 ble/prompt/update/.eval-prompt_command ble-edit/exec:gexec/invoke-hook-with-setexit PRECMD ble-edit/adjust-PS1 fi + + local ps1=$_ble_edit_PS1 rps1=$bleopt_prompt_rps1 + if [[ $is_leave_rewrite ]]; then + [[ $ps1f || $ps1t ]] && ps1=$ps1f + [[ $ps1f ]] && rps1=$rps1f + ble/textarea#invalidate + fi local trace_hash esc ble/prompt/.instantiate "$ps1" show-mode-in-prompt "${_ble_edit_prompt[@]:1}" && _ble_edit_prompt_dirty=1