-
Notifications
You must be signed in to change notification settings - Fork 212
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
Initialize LSP progress token before using it and remove progress for sync plugins #328
Initialize LSP progress token before using it and remove progress for sync plugins #328
Conversation
00fb232
to
03c5372
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rchl, could you take a look at this one? Thanks! |
a25efc4
to
aad98aa
Compare
aad98aa
to
8dfcce7
Compare
Though This hypothetical issue would rather apply to requests like |
@syphar, I'm really not sure what to do about this. As @rchl said, this could generate unexpected results if the document state changed with respect to the state used by a request being processed on a thread. Is there another way to handle this that you can think of? |
I believe I don't know enough about JSON-RPC & LSP in general, and From what I saw, I wasn't able to receive the answer for the initialize-token request, while synchronously handling the request from the editor. So while I definitely don't rule out the possibility that there is a better way of doing this, I can't see it right now. I can leave this on my list, but finding a way will first need some reading & testing on how the protocol & the implementation works. If no one can provide a hint ;) |
I've run this scenario using definitions instead of references and adding What I found is precisely what @rchl predicted: an error in the server because the line is not available anymore.
@syphar, I think for this to work the server needs to be fully async-aware. There's some work to make And given what @rchl reported on issue #325, I think the best we can do for now is to remove progress reporting (with the exception of linting, perhaps) because it's not working as expected. |
Thank you for testing!
Thanks for the info, this sounds like some more work.
That's up to you to decide of course. In my mind, even though we're not following the standard, progress reporting works (without this PR), with the exception of sublime text. |
But the standard is there for a reason. So, to clarify my previous point: I think we should leave progress reporting, along with the changes you've done in this PR to make it LSP compliant. But we should remove it from definitions, references, formatting and renames until the server is async-aware (that would preserve linting, which is the request you need it for, right?) |
I assume you mean the changes from this PR, without the threading / async change. I can probably invest some time into this the next days. The only concern I would personally have with this is that the implementation of progress reporting would just hang when used in the wrong way (in a sync handler), which could be confusing for plugin developers. I'll check if I can make it fail in these cases.
Personally I needed it primarily for linting, but also for definitions. But I totally understand your reasoning from a project viewpoint, so that's fine with me. To elaborate on my need with definitions: But I'll find another way, perhaps adding status reporting as a lua-wrapper, and/or showing an error message when no definition can be found. |
Right.
Great! Thanks for your help with that.
Good point. If you don't manage to make it fail, then we can add a mention to our docs (which are under the
Ok, thanks for understanding. |
@ccordoba12 so, I invested some time into this PR today.
What do you think about these changes now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of small suggestions and a question, otherwise looks good to me @syphar.
If the client provides a I guess it's technically not an error to still create a token like this code does but just saying. |
BTW. We've implemented a workaround in ST some time ago for servers that don't create a token so it was not a problem anymore. But those changes appear to work fine too. |
@rchl, are you ok with this now? Just checking before merging. |
yeah, fine by me |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @syphar!
This now initializes a progress token before using it.
I'm don't have much experience with json-rpc & LSP implementation details, the adapted tests & fixtures stem from my little understanding.
I'm happy to add any needed adaptions.
Fixes #325