diff --git a/pyls/python_ls.py b/pyls/python_ls.py index 04a3b42f..9e091413 100644 --- a/pyls/python_ls.py +++ b/pyls/python_ls.py @@ -291,10 +291,12 @@ def hover(self, doc_uri, position): def lint(self, doc_uri, is_saved): # Since we're debounced, the document may no longer be open workspace = self._match_uri_to_workspace(doc_uri) + textDocument = workspace.get_maybe_document(doc_uri) if doc_uri in workspace.documents: workspace.publish_diagnostics( doc_uri, - flatten(self._hook('pyls_lint', doc_uri, is_saved=is_saved)) + flatten(self._hook('pyls_lint', doc_uri, is_saved=is_saved)), + textDocument.version if textDocument else None ) def references(self, doc_uri, position, exclude_declaration): diff --git a/pyls/workspace.py b/pyls/workspace.py index e3a7e7ab..4e5f4c1e 100644 --- a/pyls/workspace.py +++ b/pyls/workspace.py @@ -104,8 +104,12 @@ def update_config(self, settings): def apply_edit(self, edit): return self._endpoint.request(self.M_APPLY_EDIT, {'edit': edit}) - def publish_diagnostics(self, doc_uri, diagnostics): - self._endpoint.notify(self.M_PUBLISH_DIAGNOSTICS, params={'uri': doc_uri, 'diagnostics': diagnostics}) + def publish_diagnostics(self, doc_uri, diagnostics, version): + self._endpoint.notify(self.M_PUBLISH_DIAGNOSTICS, params={ + 'uri': doc_uri, + 'diagnostics': diagnostics, + 'version': version + }) def show_message(self, message, msg_type=lsp.MessageType.Info): self._endpoint.notify(self.M_SHOW_MESSAGE, params={'type': msg_type, 'message': message})