@@ -281,6 +281,7 @@ def __init__(self, message_queue, project_path, server_info, server_name, enable
281
281
self .workspace_symbol_provider = False
282
282
self .inlay_hint_provider = False
283
283
self .semantic_tokens_provider = False
284
+ self .save_file_provider = False
284
285
285
286
self .work_done_progress_title = ""
286
287
@@ -538,21 +539,22 @@ def send_did_rename_files_notification(self, old_filepath, new_filepath):
538
539
})
539
540
540
541
def send_did_save_notification (self , filepath , buffer_name ):
541
- args = {
542
- "textDocument" : {
543
- "uri" : path_to_uri (filepath )
544
- }
545
- }
546
-
547
- # Fetch buffer whole content to LSP server if server capability 'includeText' is True.
548
- if self .save_include_text :
549
- args = merge (args , {
542
+ if self .save_file_provider :
543
+ args = {
550
544
"textDocument" : {
551
- "text " : get_buffer_content (filepath , buffer_name )
545
+ "uri " : path_to_uri (filepath )
552
546
}
553
- })
547
+ }
548
+
549
+ # Fetch buffer whole content to LSP server if server capability 'includeText' is True.
550
+ if self .save_include_text :
551
+ args = merge (args , {
552
+ "textDocument" : {
553
+ "text" : get_buffer_content (filepath , buffer_name )
554
+ }
555
+ })
554
556
555
- self .sender .send_notification ("textDocument/didSave" , args )
557
+ self .sender .send_notification ("textDocument/didSave" , args )
556
558
557
559
def send_workspace_did_change_watched_files (self , filepath , change_type ):
558
560
self .sender .send_notification ("workspace/didChangeWatchedFiles" , {
@@ -758,7 +760,8 @@ def save_attribute_from_message(self, message):
758
760
]),
759
761
("save_include_text" , ["result" , "capabilities" , "textDocumentSync" , "save" , "includeText" ]),
760
762
("text_document_sync" , ["result" , "capabilities" , "textDocumentSync" ]),
761
- ("semantic_tokens_provider" , ["result" , "capabilities" , "semanticTokensProvider" ])]
763
+ ("semantic_tokens_provider" , ["result" , "capabilities" , "semanticTokensProvider" ]),
764
+ ("save_file_provider" , ["result" , "capabilities" , "textDocumentSync" , "willSave" ])]
762
765
763
766
for attr , path in attributes_to_set :
764
767
self .set_attribute_from_message (message , attr , path )
0 commit comments