@@ -818,14 +818,9 @@ class NotebookDocumentSyncFeatureProvider implements NotebookDocumentSyncFeature
818
818
return undefined ;
819
819
}
820
820
for ( const item of this . options . notebookSelector ) {
821
- if ( item . notebook === undefined ) {
822
- if ( item . cells === undefined ) {
823
- return undefined ;
824
- }
821
+ if ( item . notebook === undefined || $NotebookDocumentFilter . matchNotebook ( item . notebook , notebookDocument ) ) {
825
822
const filtered = this . filterCells ( notebookDocument , cells , item . cells ) ;
826
823
return filtered . length === 0 ? undefined : filtered ;
827
- } else if ( $NotebookDocumentFilter . matchNotebook ( item . notebook , notebookDocument ) ) {
828
- return item . cells === undefined ? cells : this . filterCells ( notebookDocument , cells , item . cells ) ;
829
824
}
830
825
}
831
826
return undefined ;
@@ -836,14 +831,14 @@ class NotebookDocumentSyncFeatureProvider implements NotebookDocumentSyncFeature
836
831
return cells !== undefined && cells [ 0 ] === cell ;
837
832
}
838
833
839
- private filterCells ( notebookDocument : vscode . NotebookDocument , cells : vscode . NotebookCell [ ] , cellSelector : { language : string } [ ] ) : vscode . NotebookCell [ ] {
840
- const result = cells . filter ( ( cell ) => {
834
+ private filterCells ( notebookDocument : vscode . NotebookDocument , cells : vscode . NotebookCell [ ] , cellSelector : undefined | { language : string } [ ] ) : vscode . NotebookCell [ ] {
835
+ const filtered = cellSelector !== undefined ? cells . filter ( ( cell ) => {
841
836
const cellLanguage = cell . document . languageId ;
842
837
return cellSelector . some ( ( filter => ( filter . language === '*' || cellLanguage === filter . language ) ) ) ;
843
- } ) ;
838
+ } ) : cells ;
844
839
return typeof this . client . clientOptions . notebookDocumentOptions ?. filterCells === 'function'
845
- ? this . client . clientOptions . notebookDocumentOptions . filterCells ( notebookDocument , cells )
846
- : result ;
840
+ ? this . client . clientOptions . notebookDocumentOptions . filterCells ( notebookDocument , filtered )
841
+ : filtered ;
847
842
848
843
}
849
844
}
0 commit comments