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

IConnection#onWillSaveTextDocumentWaitUntil is never called #274

Closed
rictic opened this issue Nov 18, 2017 · 3 comments
Closed

IConnection#onWillSaveTextDocumentWaitUntil is never called #274

rictic opened this issue Nov 18, 2017 · 3 comments

Comments

@rictic
Copy link
Contributor

rictic commented Nov 18, 2017

I'm implementing a "fix lint errors on save" feature in my language server. The simplest way to do this seems to be listening for IConnection#onWillSaveTextDocumentWaitUntil and responding with some TextEdits, but my handler is never called. Same thing for IConnection#onWillSaveTextDocument and TextDocuments#onWillSaveWaitUntil.

The IConnection#onDidSaveTextDocument handler is called, and the rest of my language server is working fine (autocomplete, diagnostics, code actions, etc etc).

I'm guessing that there's probably somewhere that I need to opt into receiving these events, but I've been poking around all morning and haven't found anything.

More details:

  • my textDocumentSync capability is TextDocuments#syncKind which I think is Full
  • transport layer is stdio
  • VSCode 1.18.1, vscode-languageserver@3.5.0, vscode-languageclient@3.5.0, vscode-jsonrpc@3.5.0, vscode-languageserver-protocol@3.5.0
@rcjsuen
Copy link
Contributor

rcjsuen commented Nov 18, 2017

@rictic You need to set your capability as a TextDocumentSyncOptions object instead. Please refer to the protocol for more information.

return {
  capabilities: {
    textDocumentSync: {
      willSaveWaitUntil: true,
      change: TextDocumentSyncKind.Full
      /* others you may be interested in... */
    }
  }
}

rictic added a commit to rictic/vscode-languageserver-node that referenced this issue Nov 18, 2017
@rictic
Copy link
Contributor Author

rictic commented Nov 18, 2017

Perfect! I totally missed that. Thank you!

I sent over a PR adding some docs to that effect to help the next person in my shoes :)

@rictic rictic closed this as completed Nov 18, 2017
@dbaeumer
Copy link
Member

@rcjsuen thanks for explaining this.

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants