Send `workspace/applyEdit` to client for auto-close of tags
Auto-edits like closing tags as user types should be implemented using the standard workspace/applyEdit command.
Basically, the LS would listen to documentChange (so far, so good), and when it is detected that an opening tag was closed (like <hello>, it should send the workspace/applyEdit command to add the </hello> tag at the right location).
I think we can probably switch to using workspace/applyEdit easily, but it won't be sent on documentChange for the moment.
So far, the whole document is sent to the server (an experimental incremental mode exists but is largely untested), detecting the precise location where a tag needs closing requires a more precise range.
detecting the precise location where a tag needs closing requires a more precise range.
I think the LS can try to compare the previous document state with the current one on documentChange to sort out the smaller grain change can trigger an auto-edit. But at this point, I guess it's the same difficulty than implementing incremental mode...
I'd be more inclined to (ab)use the completion request instead
That would be already a nice way to provide a good chunk of value.
This issue is implemented by https://github.com/NikolasKomonen/lsp4xml/tree/autoCompletionMigration but because the LSP does not allow snippets in applyEdit's it will not be merged.
This issue is marked as "blocked by LSP", but in reality, isn't it more blocked by lack of support for incremental changes in lsp4xml?
@mickaelistria I started working on this issue, but using the applyEdit method didn't allow for selecting the cursor position (using a $0 ) and it always put the cursor at the end of the insert. Overall the experience is not as good as the current implementation I've found.
Ok, so this is https://github.com/Microsoft/language-server-protocol/issues/724 , isn't it?
yup, not sure if it's being worked on currently or is just in the backlog. I created a similar issue previously but it's been overridden by microsoft/language-server-protocol#724, which should be the one to follow for any updates.
Wouldn't https://microsoft.github.io/language-server-protocol/specification#textDocument_onTypeFormatting be the right thing to use here? Actually, I'm not sure clients would be expected to change the cursor position.
Wouldn't https://microsoft.github.io/language-server-protocol/specification#textDocument_onTypeFormatting be the right thing to use here?
We need to experiment it for XML. But for HTML language server it will require to do the same thing if it works
What is the currently status for this issue?