@@ -394,7 +394,7 @@ def _lint_text_document(self, doc_uri, workspace, is_saved):
394
394
flatten (self ._hook ('pylsp_lint' , doc_uri , is_saved = is_saved ))
395
395
)
396
396
397
- def _lint_notebook_document (self , notebook_document , workspace ):
397
+ def _lint_notebook_document (self , notebook_document , workspace ): # pylint: disable=too-many-locals
398
398
"""
399
399
Lint a notebook document.
400
400
@@ -443,11 +443,13 @@ def _lint_notebook_document(self, notebook_document, workspace):
443
443
for cell in cell_list :
444
444
cell_diagnostics = []
445
445
for diagnostic in document_diagnostics :
446
- if diagnostic ['range' ]['start' ]['line' ] > cell ['line_end' ] \
447
- or diagnostic ['range' ]['end' ]['line' ] < cell ['line_start' ]:
446
+ start_line = diagnostic ['range' ]['start' ]['line' ]
447
+ end_line = diagnostic ['range' ]['end' ]['line' ]
448
+
449
+ if start_line > cell ['line_end' ] or end_line < cell ['line_start' ]:
448
450
continue
449
- diagnostic ['range' ]['start' ]['line' ] = diagnostic [ 'range' ][ 'start' ][ 'line' ] - cell ['line_start' ]
450
- diagnostic ['range' ]['end' ]['line' ] = diagnostic [ 'range' ][ 'end' ][ 'line' ] - cell ['line_start' ]
451
+ diagnostic ['range' ]['start' ]['line' ] = start_line - cell ['line_start' ]
452
+ diagnostic ['range' ]['end' ]['line' ] = end_line - cell ['line_start' ]
451
453
cell_diagnostics .append (diagnostic )
452
454
453
455
workspace .publish_diagnostics (cell ['uri' ], cell_diagnostics )
@@ -528,6 +530,7 @@ def m_notebook_document__did_change(self, notebookDocument=None, change=None, **
528
530
# Cell documents
529
531
for cell_document in structure ['didClose' ]:
530
532
workspace .rm_document (cell_document ['uri' ])
533
+ workspace .publish_diagnostics (cell_document ['uri' ], [])
531
534
# Cell metadata which is removed from Notebook
532
535
workspace .remove_notebook_cells (notebookDocument ['uri' ], start , cell_delete_count )
533
536
0 commit comments