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

Feature request: Server initiated "window/showTextDocument" notification #612

Closed
rasika opened this issue Nov 23, 2018 · 18 comments
Closed
Labels
feature-request Request for new features or functionality good first issue help wanted Issues identified as good community contribution opportunities
Milestone

Comments

@rasika
Copy link

rasika commented Nov 23, 2018

I would like to request a feature which is a server-initiated notification window/showTextDocument to open and/or show text document with a given Location.

Propose Change

  • a new method: 'window/showTextDocument'
  • params: Location defined as follows:
interface Location {
	uri: DocumentUri;
	range: Range;
}

Why?
This is beneficial when text files are generated by the Server and wants clients to open / show the text document(optionally to focus specific position) in cases such as test files generation, stubs generation.

I am already aware of the CreateFile and CreateFileOptions still it won't allow to focus on specific position for a Server initiated notification(please correct me if I am wrong here).

WDYT?

@dbaeumer
Copy link
Member

Makes sense to me. @rasika would you be will on working on a PR for this. I can assist and there is a guideline on how to do this: https://github.com/Microsoft/language-server-protocol/blob/master/contributing.md

I would make it a request to be able to return an indication if the opening was successful or failed.

@dbaeumer dbaeumer added this to the On Deck milestone Dec 11, 2018
@dbaeumer dbaeumer added feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities good first issue labels Dec 11, 2018
@rasika
Copy link
Author

rasika commented Dec 12, 2018

@dbaeumer Thanks for the info. Sure, I'll proceed with the PR.

@dbaeumer
Copy link
Member

@rasika just to clarify. We need a PR here and in https://github.com/Microsoft/vscode-languageserver-node since at least one implementation is necessary as well.

@rcjsuen
Copy link
Contributor

rcjsuen commented Dec 12, 2018

Would it make sense to send an array so that you can open multiple files or just send multiple requests?

@dbaeumer
Copy link
Member

I am fine sending an array.

@rasika
Copy link
Author

rasika commented Dec 13, 2018

@rcjsuen +1 for the array. Will implement accordingly.

@matklad
Copy link
Contributor

matklad commented Dec 22, 2018

I am personally not a huge fan of serve-initiated requests to change the state of the client, because they break the causality: you can't reliably infer what was the cause of the request.

I'd rather we add an ability to focus specific document when applying edits. @rasika would it work for your if WorkspaceEdit had a focus array which described documents and locations editor should reveal after applying the edit?

@dbaeumer I would also appreciate an ability to focus a specific position after a document edit, and a specific document after workspace edit. In my rust-server, I use a bespoke implementation of edits to have this feature. I need it in two cases:

  • I have "create module" quick fix, which creates a new file, which better be focused
  • SIngle-file code actions would like to move cursor to a specific position in the newly generated code.

@dbaeumer
Copy link
Member

@matklad I would suggest to track this in another issue.

@rasika Could we make this a request instead of a notification. The open for example could fail for some reason.

@rasika
Copy link
Author

rasika commented Jan 21, 2019

@dbaeumer sorry couldn't track this thread after the vacation. Apparently can implement as a Request. Will start working on it today.

@matklad
Copy link
Contributor

matklad commented Jan 21, 2019

@rasika could you clarify if you need a completely separate request to show arbitrary text document, or if you have a more specific requirement of "open a text document after creating it using CreateFile resource operation"?

@rasika
Copy link
Author

rasika commented Jan 21, 2019

Replied to #663; adding a comment here for the future reference.

@darkbasic
Copy link

@rasika any news on the PR?
I'm adding resolvers finding capabilities to the GraphQL for VSCode extension (https://youtu.be/qBh6-Pd5Otw) and I definitely need this.
As you can see, in the video I'm still using the Go To Definition capabilities so everything's fine, but I've recently moved to CodeLens and I've found no way to initiate a showTextDocument from the server.
0
Basically I have a Location object for each resolver and when the user clicks on Go to Resolver I want VSCode to open it and focus on it.

@darkbasic
Copy link

Since @rasika didn't answer I decided to give it a try: microsoft/vscode-languageserver-node#490

You're gonna use it this way:

await connection
  .sendRequest(ShowTextDocumentRequest.type.method, {
    fileName,
    options: {
      selection,
  })

I just implemented it for the node server without making any protocol proposal, because I'd like to discuss it little bit to see if there is anything that you would like to change before.

@rasika
Copy link
Author

rasika commented Apr 29, 2019

Apology for the late reply. Please go ahead. Won't be able to actively contribute due to recent workload spike in my day job.

@darkbasic
Copy link

I just signed the CLA, let me know if there is anything else I can do to get such feature merged. We rely on it to release the next version of the graphql-for-vscode extension.

@dbaeumer dbaeumer modified the milestones: On Deck, 3.16 Sep 18, 2019
@KamasamaK
Copy link
Contributor

The actual client capability does not appear to have been added.

@KamasamaK
Copy link
Contributor

It happened again, so I've just opened a PR #1138 instead of posting another comment in another closed issue.

@dbaeumer
Copy link
Member

@KamasamaK thanks. Merged the PR.

@vscodebot vscodebot bot locked and limited conversation to collaborators Dec 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality good first issue help wanted Issues identified as good community contribution opportunities
Projects
None yet
Development

No branches or pull requests

6 participants