From 647db2172a00454d2f4b3cbc733b227ea6b8bf44 Mon Sep 17 00:00:00 2001 From: Miles Ziemer Date: Wed, 6 Nov 2024 16:04:43 -0500 Subject: [PATCH] Fix document sync registrations on init Fixes a bug in #168 where the server would send the wrong registration for didSave on Smithy files. --- .../java/software/amazon/smithy/lsp/SmithyLanguageServer.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/software/amazon/smithy/lsp/SmithyLanguageServer.java b/src/main/java/software/amazon/smithy/lsp/SmithyLanguageServer.java index f8917ce..3e7ce8b 100644 --- a/src/main/java/software/amazon/smithy/lsp/SmithyLanguageServer.java +++ b/src/main/java/software/amazon/smithy/lsp/SmithyLanguageServer.java @@ -298,6 +298,7 @@ private void registerDocumentSynchronization() { changeBuildOpts.setDocumentSelector(buildDocumentSelector); var saveBuildOpts = new TextDocumentSaveRegistrationOptions(); saveBuildOpts.setDocumentSelector(buildDocumentSelector); + saveBuildOpts.setIncludeText(true); client.registerCapability(new RegistrationParams(List.of( new Registration("SyncSmithyBuildFiles/Open", "textDocument/didOpen", openCloseBuildOpts), @@ -320,12 +321,13 @@ private void registerDocumentSynchronization() { changeSmithyOpts.setDocumentSelector(smithyDocumentSelector); var saveSmithyOpts = new TextDocumentSaveRegistrationOptions(); saveSmithyOpts.setDocumentSelector(smithyDocumentSelector); + saveSmithyOpts.setIncludeText(true); client.registerCapability(new RegistrationParams(List.of( new Registration("SyncSmithyFiles/Open", "textDocument/didOpen", openCloseSmithyOpts), new Registration("SyncSmithyFiles/Close", "textDocument/didClose", openCloseSmithyOpts), new Registration("SyncSmithyFiles/Change", "textDocument/didChange", changeSmithyOpts), - new Registration("SyncSmithyFiles/Save", "textDocument/didSave", saveBuildOpts)))); + new Registration("SyncSmithyFiles/Save", "textDocument/didSave", saveSmithyOpts)))); } @Override