olets / zsh-abbr

The zsh manager for auto-expanding abbreviations, inspired by fish. ~13,000 unique cloners as of May '24, 580+ Homebrew installs 6/23-6/24
https://zsh-abbr.olets.dev
Other
510 stars 18 forks source link

If zsh-autosuggestions is not present, an error calling `_zsh_autosuggest_clear` will be frequently be displayed #28

Closed jwcxz closed 3 years ago

jwcxz commented 3 years ago

I installed zsh-abbr without having zsh-autosuggestions installed. The call to _zsh_autosuggest_clear therefore caused an error to be printed in the shell frequently (when _abbr_widget_expand_and_accept is called).

I solved this with the following change, but I'm sure there are better ways:

--- zsh-abbr.zsh.old    2020-10-29 10:42:06.000000000 -0700
+++ zsh-abbr.zsh    2020-10-29 10:42:40.000000000 -0700
@@ -1260,7 +1260,10 @@
     zle _abbr_widget_expand
   fi

-  _zsh_autosuggest_clear
+  # https://unix.stackexchange.com/questions/332005/test-for-functions-existence-that-can-work-on-both-bash-and-zsh/332010
+  if type '_zsh_autosuggest_clear' 2>/dev/null | grep -q 'function'; then
+    _zsh_autosuggest_clear
+  fi

   zle accept-line
 }
olets commented 3 years ago

Thanks for the report! Recently changed how that worked, knew there was a reason I had it the way it was. Lesson: don't cut releases in the week of getting married! Should be fixed in 4.1.2, go ahead and close this if it is

olets commented 3 years ago

Closing — no activity in two weeks, and no other reports of this problem since 4.1.2's release

jwcxz commented 3 years ago

Apologies for forgetting to respond and close! The changes mentioned definitely resolve this issue, thanks.

(And, congratulations!)

olets commented 3 years ago

No problem, I've been on the other side of that myself 👍

Thanks! 🎉

olets commented 1 month ago

Belatedly recognizing bug reporters in https://github.com/olets/zsh-abbr#community and https://zsh-abbr.olets.dev/community/. would you like to be added @jwcxz?