Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use funcref() instead of function() for closures used as callbacks #1155

Merged
merged 1 commit into from
Dec 28, 2016

Conversation

bhcleek
Copy link
Collaborator

@bhcleek bhcleek commented Dec 28, 2016

Use funcref() instead of function() to get a Funcref that will retrieve
the function by reference instead of by name. function() returns a
Funcref that resolves the function by name, which caused multiple
concurrent jobs of the same type to both execute the callback that
closed over the arguments of the last job to be started. funcref()
returns a Funcref that returns the function by reference (not by name),
so each job is assured that its callbacks execute the function that
closed over the arguments of that job.

Also refactored a couple of the guru functions to check the result of
guru_cmd for stdin_content explicitly instead of assuming that
guru_cmd's result has a stdin_content key when the buffer is modified.

The easiest way to see the problems that this PR addresses is to set g:go_auto_sameids=1, and then run GoReferrers on some reference. One would expect the location list to be opened, but it never did.

Use funcref() instead of function() to get a Funcref that will retrieve
the function by reference instead of by name. function() returns a
Funcref that resolves the function by name, which caused multiple
concurrent jobs of the same type to both execute the callback that
closed over the arguments of the last job to be started. funcref()
returns a Funcref that returns the function by reference (not by name),
so each job is assured that its callbacks execute the function that
closed over the arguments of that job.

Also refactored a couple of the guru functions to check the result of
guru_cmd for stdin_content explicitly instead of assuming that
guru_cmd's result has a stdin_content key when the buffer is modified.
@fatih fatih merged commit edcd9c8 into fatih:master Dec 28, 2016
@fatih
Copy link
Owner

fatih commented Dec 28, 2016

Thanks @bhcleek, nice fix 👍

@bhcleek bhcleek deleted the fix-guru-async branch December 28, 2016 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants