Skip to content

Commit

Permalink
Improve logging & bug reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonrichert committed Oct 5, 2021
1 parent 7b1a81c commit 3d97f06
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ assignees: ''
<!-- Replace the contents of this block with the output of the commands below: -->
```zsh
git -C ~zsh-autocomplete log --oneline -n1
print $_autocomplete__funcfiletrace
print -l $_autocomplete__funcfiletrace
print $VENDOR $OSTYPE $SHELL $ZSH_ARGZERO $ZSH_PATCHLEVEL
```

Expand Down
12 changes: 9 additions & 3 deletions scripts/.autocomplete.__init__
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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

Expand Down
14 changes: 7 additions & 7 deletions scripts/.autocomplete.async
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand All @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion zsh-autocomplete.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3d97f06

Please sign in to comment.