-
Notifications
You must be signed in to change notification settings - Fork 78
Respect server document sync capabilities #202
Respect server document sync capabilities #202
Conversation
The problem is that openClose capabilities flag does not exist in LSP v2 but didSave and didOpen messages do so back in v2 you definitely had to always send it to be compliant. There is no version level negotiation between a client and server and we definitely still want to support v2 servers so I think what you've done here - defaulting to sending it unless specified otherwise - is the right thing to do. Save and open events are quite lightweight so I don't think it's too bad for a server to just ignore what they don't want.
I thought that one was capabilities flagged but it seems that was missed. |
OK, I see that the current behaviour is justified by the compatibility with LSP v2.
But in this particular context there is clear distinction between v2 and v3: the type of the sync options is either this._documentSync = {
openClose: true,
change: documentSync || TextDocumentSyncKind.Full,
save: { includeText: false }, // not sure what was the default in v2
// willSave options were not present in v2 AFAIK
}; While if the server sends On the second thought, it doesn't make much difference anyway... So don't mind it.
I guess, fixing this will require implementing #155 first. |
That logic sounds good to me but like you I could go either way so it's up to you :) |
Let's leave it as is. Now there is an option to disable those features (except |
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.
Looks awesome, thanks a lot for making this improvement!
If this is approved, could you merge it and publish a new release? |
Thanks! |
See #193 (comment) for the context. This is a minor improvement avoiding breaking changes:
didOpen
/didClose
notifications ifdocumentSync.openClose
is explicitly disableddocumentSync.save.includeText
is enabledAnd here are some thoughts for discussion.
I think that current behaviour is not completely correct, but fixing it may break somebody's server. IMO in LSP v3 all capability options have to be enabled explicitly. So if the server wants to receive open/close notifications, it should set
openClose: true
, same aswillSave
/willSaveWaitUntil
.willSave*
has to be enabled explicitly, butopenClose
andsave
not.open
/close
/willSave*
notifications, but cannot disablesave
(because it's not a boolean and undefined is implicitly treated astrue
)change
option is treated specially: it determines whether all other notifications are even consideredAn example: if a server cares only about
open
,close
andwillSaveWaitUntil
notifications, but doesn't want to receive any other, it cannot communicate it. Turning offchange
notifications while receiving some others can be useful if server has its own file watching mechanism. But currently it will result inDocumentSyncAdapter.canAdaptV3
returningfalse
and not receiving any notifications at all.Also, I'm not sure about this, but I think that
didChangeWatchedFiles
notifications have to be registered independently from all above.