Don't reset hippie-expand search string #1168
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
hippie-expand relies on the values of this-command and last-command in
order to determine what argument it should pass to try-expand
functions, in order to signal whether it's the "first" time they are
being called.
However, undo (even when called interactively) sets itself as
this-command, which breaks hippie-expand. This has the following
concrete effect: suppose there are two dabbrevs for "ab" in the
buffer, "abc" and "abcd" (occurring in that order, before point).
Also, suppose there is a yasnippet whose key is "ab", and yasnippet
comes before dabbrev in the hippie-expand-try-functions-list.
If a user presses "a b" and then M-/ (hippie-expand), repeatedly, what
happens on each M-/ is:
Dabbrev inserts "abcd". However, yasnippet-hippie-try-expand also
caused this-command to be set to undo.
last-command (undo), and so the search string is set to "abcd"
instead of "ab". There are no further occurrences of "abcd" in the
buffer, and if the user was trying to expand "abc" (or any other
string beginning with "ab" but not "abcd"), this fails.
This PR fixes the above bug by resetting this-command to the value
it had before undo was called. Since we do not care about chaining
consecutive undos in this context, this doesn't break undo, and it
fixes the above issue with hippie-expand.