@@ -215,10 +215,13 @@ def hover(self, doc_uri, position):
215215 return self ._hook ('pyls_hover' , doc_uri , position = position ) or {'contents' : '' }
216216
217217 @_utils .debounce (LINT_DEBOUNCE_S , keyed_by = 'doc_uri' )
218- def lint (self , doc_uri ):
218+ def lint (self , doc_uri , is_saved ):
219219 # Since we're debounced, the document may no longer be open
220220 if doc_uri in self .workspace .documents :
221- self .workspace .publish_diagnostics (doc_uri , flatten (self ._hook ('pyls_lint' , doc_uri )))
221+ self .workspace .publish_diagnostics (
222+ doc_uri ,
223+ flatten (self ._hook ('pyls_lint' , doc_uri , is_saved = is_saved ))
224+ )
222225
223226 def references (self , doc_uri , position , exclude_declaration ):
224227 return flatten (self ._hook (
@@ -238,7 +241,7 @@ def m_text_document__did_close(self, textDocument=None, **_kwargs):
238241 def m_text_document__did_open (self , textDocument = None , ** _kwargs ):
239242 self .workspace .put_document (textDocument ['uri' ], textDocument ['text' ], version = textDocument .get ('version' ))
240243 self ._hook ('pyls_document_did_open' , textDocument ['uri' ])
241- self .lint (textDocument ['uri' ])
244+ self .lint (textDocument ['uri' ], is_saved = False )
242245
243246 def m_text_document__did_change (self , contentChanges = None , textDocument = None , ** _kwargs ):
244247 for change in contentChanges :
@@ -247,10 +250,10 @@ def m_text_document__did_change(self, contentChanges=None, textDocument=None, **
247250 change ,
248251 version = textDocument .get ('version' )
249252 )
250- self .lint (textDocument ['uri' ])
253+ self .lint (textDocument ['uri' ], is_saved = False )
251254
252255 def m_text_document__did_save (self , textDocument = None , ** _kwargs ):
253- self .lint (textDocument ['uri' ])
256+ self .lint (textDocument ['uri' ], is_saved = True )
254257
255258 def m_text_document__code_action (self , textDocument = None , range = None , context = None , ** _kwargs ):
256259 return self .code_actions (textDocument ['uri' ], range , context )
@@ -294,7 +297,7 @@ def m_text_document__signature_help(self, textDocument=None, position=None, **_k
294297 def m_workspace__did_change_configuration (self , settings = None ):
295298 self .config .update ((settings or {}).get ('pyls' , {}))
296299 for doc_uri in self .workspace .documents :
297- self .lint (doc_uri )
300+ self .lint (doc_uri , is_saved = False )
298301
299302 def m_workspace__did_change_watched_files (self , changes = None , ** _kwargs ):
300303 changed_py_files = set (d ['uri' ] for d in changes if d ['uri' ].endswith (PYTHON_FILE_EXTENSIONS ))
@@ -306,7 +309,7 @@ def m_workspace__did_change_watched_files(self, changes=None, **_kwargs):
306309 for doc_uri in self .workspace .documents :
307310 # Changes in doc_uri are already handled by m_text_document__did_save
308311 if doc_uri not in changed_py_files :
309- self .lint (doc_uri )
312+ self .lint (doc_uri , is_saved = False )
310313
311314 def m_workspace__execute_command (self , command = None , arguments = None ):
312315 return self .execute_command (command , arguments )
0 commit comments