@@ -51,10 +51,10 @@ export type OnFileChangeCallback = (data: OnFileChangeData) => void;
5151export type OnOperationAppliedCallback = ( data : OnOperationAppliedData ) => void ;
5252
5353export type ModuleModel = {
54- changeListener : { dispose : Function } ;
54+ changeListener : { dispose : Function } | null ;
5555 currentLine : number ;
5656 path : string ;
57- model : Promise < any > ;
57+ model : Promise < any > | null ;
5858 comments : Array < { commentId : string ; range : [ number , number ] } > ;
5959 currentCommentDecorations : string [ ] ;
6060} ;
@@ -91,8 +91,9 @@ export class ModelsHandler {
9191 this . modelAddedListener . dispose ( ) ;
9292 this . modelRemovedListener . dispose ( ) ;
9393 Object . keys ( this . moduleModels ) . forEach ( path => {
94- if ( this . moduleModels [ path ] . changeListener ) {
95- this . moduleModels [ path ] . changeListener . dispose ( ) ;
94+ const changeListener = this . moduleModels [ path ] . changeListener ;
95+ if ( changeListener ) {
96+ changeListener . dispose ( ) ;
9697 }
9798 } ) ;
9899 this . moduleModels = { } ;
@@ -300,7 +301,7 @@ export class ModelsHandler {
300301 public async setModuleCode ( module : Module ) {
301302 const moduleModel = this . getModuleModelByPath ( module . path ) ;
302303
303- if ( moduleModel ? .model ) {
304+ if ( ! moduleModel || ! moduleModel . model ) {
304305 return ;
305306 }
306307 const model = await moduleModel . model ;
@@ -706,7 +707,11 @@ export class ModelsHandler {
706707 this . modelRemovedListener = this . editorApi . textFileService . modelService . onModelRemoved (
707708 model => {
708709 if ( this . moduleModels [ model . uri . path ] ) {
709- this . moduleModels [ model . uri . path ] . changeListener . dispose ( ) ;
710+ const changeListener = this . moduleModels [ model . uri . path ]
711+ . changeListener ;
712+ if ( changeListener ) {
713+ changeListener . dispose ( ) ;
714+ }
710715
711716 const csbPath = model . uri . path . replace ( '/sandbox' , '' ) ;
712717 dispatch ( actions . correction . clear ( csbPath , 'eslint' ) ) ;
0 commit comments