File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -342,10 +342,17 @@ pub(crate) fn lint_path(
342342 }
343343 }
344344
345- let notebook_indexes = if let SourceKind :: IpyNotebook ( notebook) = transformed {
346- FxHashMap :: from_iter ( [ ( path. to_string_lossy ( ) . to_string ( ) , notebook. into_index ( ) ) ] )
347- } else {
345+ // Avoid constructing a map when there are no diagnostics. The index is only used for rendering
346+ // diagnostics anyway. This mirrors our caching behavior, which does not preserve an empty index
347+ // either.
348+ let notebook_indexes = if diagnostics. is_empty ( ) {
348349 FxHashMap :: default ( )
350+ } else {
351+ if let SourceKind :: IpyNotebook ( notebook) = transformed {
352+ FxHashMap :: from_iter ( [ ( path. to_string_lossy ( ) . to_string ( ) , notebook. into_index ( ) ) ] )
353+ } else {
354+ FxHashMap :: default ( )
355+ }
349356 } ;
350357
351358 Ok ( Diagnostics {
You can’t perform that action at this time.
0 commit comments