You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I tried to let copilot run automatically, but wasn't successful to do so. I used the TRAPALRM function with TMOUT to run a function every few seconds to detect whether the user finished typing. While this worked, showing suggestions or changing the BUFFER does not seem to be allowed by zsh. I tried calling the widget to let it handle the situation, but was unable to find a solution.
If someone knows a way how to do this, I'd be happy about PRs.
Here's the code I used:
# Global variableslocal last_input_hash=""# This is the hash to which the last suggestion happened against. This is used to prevent multiple suggestions for the same inputlocal last_suggested_input_hash=""
TMOUT=2
TRAPALRM() {
if [[ "$BUFFER"=="" ]];then
last_input_hash=""returnfi# content plus lengthlocal hash=$(echo "$BUFFER-${#BUFFER}")if [[ "$hash"=="$last_suggested_input_hash" ]];thenreturnfiif [[ "$hash"!="$last_input_hash" ]];then# User is still typing
last_input_hash="$hash"elseif [[ $is_suggesting=='false' ]];then
_suggest_ai
last_suggested_input_hash="$hash"fifi
}
The text was updated successfully, but these errors were encountered:
So I tried to let copilot run automatically, but wasn't successful to do so. I used the
TRAPALRM
function withTMOUT
to run a function every few seconds to detect whether the user finished typing. While this worked, showing suggestions or changing theBUFFER
does not seem to be allowed by zsh. I tried calling the widget to let it handle the situation, but was unable to find a solution.If someone knows a way how to do this, I'd be happy about PRs.
Here's the code I used:
The text was updated successfully, but these errors were encountered: