From 3d97f06f59e174c1ef990938261aea57a380f430 Mon Sep 17 00:00:00 2001 From: Marlon Richert Date: Tue, 5 Oct 2021 06:29:34 +0300 Subject: [PATCH] Improve logging & bug reporting --- .github/ISSUE_TEMPLATE/bug-report.md | 2 +- scripts/.autocomplete.__init__ | 12 +++++++++--- scripts/.autocomplete.async | 14 +++++++------- zsh-autocomplete.plugin.zsh | 2 +- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index 590e2882..1dd25f68 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -13,7 +13,7 @@ assignees: '' ```zsh git -C ~zsh-autocomplete log --oneline -n1 -print $_autocomplete__funcfiletrace +print -l $_autocomplete__funcfiletrace print $VENDOR $OSTYPE $SHELL $ZSH_ARGZERO $ZSH_PATCHLEVEL ``` diff --git a/scripts/.autocomplete.__init__ b/scripts/.autocomplete.__init__ index 83068177..c8691f60 100644 --- a/scripts/.autocomplete.__init__ +++ b/scripts/.autocomplete.__init__ @@ -61,7 +61,10 @@ private logdir=$xdg_data_home/zsh-autocomplete/log private -a older_than_a_week=( $logdir/*(Nmd+7) ) (( $#older_than_a_week[@] )) && zf_rm -f -- $older_than_a_week[@] -typeset -gH _autocomplete__log_file=$logdir/${(%):-%D{%F}}.log +private date=${(%):-%D{%F}} +typeset -gH _autocomplete__log=$logdir/$date.log +typeset -gH _autocomplete__log_async=$logdir/$date.async.log +typeset -gH _autocomplete__log_pty=$logdir/$date.pty.log typeset -gH _autocomplete__prev=' ' _autocomplete__next=$'\n# %e. %N' typeset -gH _autocomplete__time=$' [%D{%T.%.}]\n' @@ -78,8 +81,11 @@ private mod= for mod in compinit config widget key-binding recent-dirs async; do if builtin zstyle -T ':autocomplete:' $mod; then builtin autoload -Uz ~zsh-autocomplete/scripts/.autocomplete.$mod - .autocomplete.$mod "$@" - unfunction .autocomplete.$mod + { + .autocomplete.$mod "$@" + } always { + unfunction .autocomplete.$mod + } fi done diff --git a/scripts/.autocomplete.async b/scripts/.autocomplete.async index f249cf56..beae03ed 100644 --- a/scripts/.autocomplete.async +++ b/scripts/.autocomplete.async @@ -246,7 +246,7 @@ builtin zle -N history-incremental-search-forward .autocomplete.async.history-in # $_autocomplete__async_complete_fd (if necessary). print -rNC1 -- "$SECONDS" "${text%$'\0\C-C'}" } -} 2>>| $_autocomplete__log_file +} 2>>| $_autocomplete__log_async log_functions+=( .autocomplete.async.start.inner ) .autocomplete.async.pty() { @@ -255,7 +255,7 @@ log_functions+=( .autocomplete.async.start.inner ) builtin bindkey $'\t' .autocomplete.async.pty.zle-widget local __tmp__= builtin vared __tmp__ -} 2>>| $_autocomplete__log_file +} 2>>| $_autocomplete__log_pty log_functions+=( .autocomplete.async.pty ) .autocomplete.async.pty.no-op() { @@ -283,7 +283,7 @@ log_functions+=( .autocomplete.async.pty ) "$_autocomplete__list_lines" "$_autocomplete__mesg" "$_autocomplete__comp_mesg[@]" '\C-C' builtin kill $sysparams[pid] } -} 2>>| $_autocomplete__log_file +} 2>>| $_autocomplete__log_pty log_functions+=( .autocomplete.async.pty.zle-widget.inner ) .autocomplete.async.pty.completion-widget() { @@ -323,7 +323,7 @@ log_functions+=( .autocomplete.async.pty.zle-widget.inner ) } always { typeset -gHi _autocomplete__list_lines=$compstate[list_lines] } -} 2>>| $_autocomplete__log_file +} 2>>| $_autocomplete__log_pty log_functions+=( .autocomplete.async.pty.completion-widget.inner ) .autocomplete.async.pty.message() { @@ -362,7 +362,7 @@ log_functions+=( .autocomplete.async.pty.completion-widget.inner ) setopt $_autocomplete__comp_opts[@] [[ -n $curcontext ]] && setopt $_autocomplete__ctxt_opts[@] - if ! builtin zle ._list_choices -w "$reply[@]" 2>>| $_autocomplete__log_file; then + if ! builtin zle ._list_choices -w "$reply[@]" 2>>| $_autocomplete__log; then region_highlight=( "$_autocomplete__highlight[@]" ) [[ -v functions[_zsh_autosuggest_highlight_apply] ]] && _zsh_autosuggest_highlight_apply @@ -373,7 +373,7 @@ log_functions+=( .autocomplete.async.pty.completion-widget.inner ) .autocomplete.async.stop fi return 0 -} 2>>| $_autocomplete__log_file +} 2>>| $_autocomplete__log log_functions+=( .autocomplete.async.complete.fd-widget.inner ) .autocomplete.async.insufficient-input() { @@ -437,7 +437,7 @@ log_functions+=( .autocomplete.async.complete.fd-widget.inner ) typeset -gHi _autocomplete__current=$CURRENT return 2 # Don't return 1, to prevent beeping. -} 2>>| $_autocomplete__log_file +} 2>>| $_autocomplete__log log_functions+=( .autocomplete.async.list-choices.completion-widget ) .autocomplete.async.list-choices.post() { diff --git a/zsh-autocomplete.plugin.zsh b/zsh-autocomplete.plugin.zsh index 3603d9ee..b3fcf692 100644 --- a/zsh-autocomplete.plugin.zsh +++ b/zsh-autocomplete.plugin.zsh @@ -13,7 +13,7 @@ setopt NO_flowcontrol NO_listbeep NO_singlelinezle () { emulate -L zsh zmodload -F zsh/parameter p:funcfiletrace p:functions - typeset -gH _autocomplete__funcfiletrace=${(F)funcfiletrace[2,-2]} + typeset -gHa _autocomplete__funcfiletrace=( $funcfiletrace[2,-2] ) typeset -gHa _autocomplete__func_opts=( localoptions extendedglob clobber