Skip to content

Maybe fix for slow pastes #238

@aaronjensen

Description

@aaronjensen

Howdy, I think I may have a solution for slow pastes (#141 #219) but I'm not sure if there are problems with it or what the best way to actually implement it is.

I believe that the paste slowdown comes from the additional zle invocation to call the original widget on self-insert. Rather than doing that, if, on disable, we replace self-insert with the original widget and then on enable, we replace it back, things are snappy.

Here is my naive implementation:

# Disable suggestions
_zsh_autosuggest_disable() {
	typeset -g _ZSH_AUTOSUGGEST_DISABLED
	_zsh_autosuggest_clear
	zle -N self-insert url-quote-magic
}

# Enable suggestions
_zsh_autosuggest_enable() {
	unset _ZSH_AUTOSUGGEST_DISABLED
	zle -N self-insert _zsh_autosuggest_bound_1_self-insert

	if [ $#BUFFER -gt 0 ]; then
		_zsh_autosuggest_fetch
	fi
}

Obviously we shouldn't hard-code url-quote-magic or _zsh_autosuggest_bound_1_self-insert but I wasn't sure of the best way to get the right ones in there.

Thoughts? Suggestions? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions