mirror of
				https://github.com/zsh-users/zsh-autosuggestions.git
				synced 2025-10-30 15:26:29 +08:00 
			
		
		
		
	Merge 7d41cf90c8 into 62cdba4e0f
				
					
				
			This commit is contained in:
		
						commit
						42f51367a6
					
				@ -1,3 +1,4 @@
 | 
			
		||||
zmodload zsh/datetime
 | 
			
		||||
 | 
			
		||||
#--------------------------------------------------------------------#
 | 
			
		||||
# Global Configuration Variables                                     #
 | 
			
		||||
@ -47,3 +48,10 @@ ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=(
 | 
			
		||||
	vi-forward-blank-word
 | 
			
		||||
	vi-forward-blank-word-end
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
# EPOCH of the last changed widget call
 | 
			
		||||
ZSH_AUTOSUGGEST_LAST_MODIFY_TIME=$EPOCHREALTIME
 | 
			
		||||
 | 
			
		||||
# Lower bound for the time between changes that will cause autosuggest
 | 
			
		||||
# to suspend suggestions for the current edit.
 | 
			
		||||
ZSH_AUTOSUGGEST_CUTOFF_PERIOD=0.05
 | 
			
		||||
 | 
			
		||||
@ -22,6 +22,14 @@ _zsh_autosuggest_modify() {
 | 
			
		||||
	_zsh_autosuggest_invoke_original_widget $@
 | 
			
		||||
	retval=$?
 | 
			
		||||
 | 
			
		||||
    local time_passed=$(($EPOCHREALTIME - $ZSH_AUTOSUGGEST_LAST_MODIFY_TIME))
 | 
			
		||||
 | 
			
		||||
    if (( $time_passed < $ZSH_AUTOSUGGEST_CUTOFF_PERIOD )); then
 | 
			
		||||
        return 1
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    ZSH_AUTOSUGGEST_LAST_MODIFY_TIME=$EPOCHREALTIME
 | 
			
		||||
 | 
			
		||||
	# Get a new suggestion if the buffer is not empty after modification
 | 
			
		||||
	local suggestion
 | 
			
		||||
	if [ $#BUFFER -gt 0 ]; then
 | 
			
		||||
 | 
			
		||||
@ -24,6 +24,7 @@
 | 
			
		||||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 | 
			
		||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 | 
			
		||||
# OTHER DEALINGS IN THE SOFTWARE.
 | 
			
		||||
zmodload zsh/datetime
 | 
			
		||||
 | 
			
		||||
#--------------------------------------------------------------------#
 | 
			
		||||
# Global Configuration Variables                                     #
 | 
			
		||||
@ -74,6 +75,13 @@ ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=(
 | 
			
		||||
	vi-forward-blank-word-end
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
# EPOCH of the last changed widget call
 | 
			
		||||
ZSH_AUTOSUGGEST_LAST_MODIFY_TIME=$EPOCHREALTIME
 | 
			
		||||
 | 
			
		||||
# Lower bound for the time between changes that will cause autosuggest
 | 
			
		||||
# to suspend suggestions for the current edit.
 | 
			
		||||
ZSH_AUTOSUGGEST_CUTOFF_PERIOD=0.05
 | 
			
		||||
 | 
			
		||||
#--------------------------------------------------------------------#
 | 
			
		||||
# Handle Deprecated Variables/Widgets                                #
 | 
			
		||||
#--------------------------------------------------------------------#
 | 
			
		||||
@ -240,6 +248,14 @@ _zsh_autosuggest_modify() {
 | 
			
		||||
	_zsh_autosuggest_invoke_original_widget $@
 | 
			
		||||
	retval=$?
 | 
			
		||||
 | 
			
		||||
    local time_passed=$(($EPOCHREALTIME - $ZSH_AUTOSUGGEST_LAST_MODIFY_TIME))
 | 
			
		||||
 | 
			
		||||
    if (( $time_passed < $ZSH_AUTOSUGGEST_CUTOFF_PERIOD )); then
 | 
			
		||||
        return 1
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    ZSH_AUTOSUGGEST_LAST_MODIFY_TIME=$EPOCHREALTIME
 | 
			
		||||
 | 
			
		||||
	# Get a new suggestion if the buffer is not empty after modification
 | 
			
		||||
	local suggestion
 | 
			
		||||
	if [ $#BUFFER -gt 0 ]; then
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user