@@ -329,17 +329,10 @@ pub(crate) fn lint_path(
329329 cache. set_linted ( relative_path. to_owned ( ) , & key, linted) ;
330330 }
331331
332- // Avoid constructing a map when there are no diagnostics. The index is only used for rendering
333- // diagnostics anyway. This mirrors our caching behavior, which does not preserve an empty index
334- // either.
335- let notebook_indexes = if diagnostics. is_empty ( ) {
336- FxHashMap :: default ( )
332+ let notebook_indexes = if let SourceKind :: IpyNotebook ( notebook) = transformed {
333+ FxHashMap :: from_iter ( [ ( path. to_string_lossy ( ) . to_string ( ) , notebook. into_index ( ) ) ] )
337334 } else {
338- if let SourceKind :: IpyNotebook ( notebook) = transformed {
339- FxHashMap :: from_iter ( [ ( path. to_string_lossy ( ) . to_string ( ) , notebook. into_index ( ) ) ] )
340- } else {
341- FxHashMap :: default ( )
342- }
335+ FxHashMap :: default ( )
343336 } ;
344337
345338 Ok ( Diagnostics {
@@ -477,19 +470,13 @@ pub(crate) fn lint_stdin(
477470 ( result, transformed, fixed)
478471 } ;
479472
480- // Avoid constructing a map when there are no diagnostics. The index is only used for rendering
481- // diagnostics anyway.
482- let notebook_indexes = if diagnostics. is_empty ( ) {
483- FxHashMap :: default ( )
473+ let notebook_indexes = if let SourceKind :: IpyNotebook ( notebook) = transformed {
474+ FxHashMap :: from_iter ( [ (
475+ path. map_or_else ( || "-" . into ( ) , |path| path. to_string_lossy ( ) . to_string ( ) ) ,
476+ notebook. into_index ( ) ,
477+ ) ] )
484478 } else {
485- if let SourceKind :: IpyNotebook ( notebook) = transformed {
486- FxHashMap :: from_iter ( [ (
487- path. map_or_else ( || "-" . into ( ) , |path| path. to_string_lossy ( ) . to_string ( ) ) ,
488- notebook. into_index ( ) ,
489- ) ] )
490- } else {
491- FxHashMap :: default ( )
492- }
479+ FxHashMap :: default ( )
493480 } ;
494481
495482 Ok ( Diagnostics {
0 commit comments