@@ -282,10 +282,10 @@ export class NativeEditorStorage implements INotebookStorage {
282282 const  dirtyContents  =  skipDirtyContents  ? undefined  : await  this . getStoredContents ( file ,  backupId ) ; 
283283 if  ( dirtyContents )  { 
284284 // This means we're dirty. Indicate dirty and load from this content 
285-  return  this . loadContents ( file ,  dirtyContents ,  true ,  contents ,   forVSCodeNotebook ) ; 
285+  return  this . loadContents ( file ,  dirtyContents ,  true ,  forVSCodeNotebook ) ; 
286286 }  else  { 
287287 // Load without setting dirty 
288-  return  this . loadContents ( file ,  contents ,  undefined ,  undefined ,   forVSCodeNotebook ) ; 
288+  return  this . loadContents ( file ,  contents ,  undefined ,  forVSCodeNotebook ) ; 
289289 } 
290290 }  catch  ( ex )  { 
291291 // May not exist at this time. Should always have a single cell though 
@@ -308,7 +308,6 @@ export class NativeEditorStorage implements INotebookStorage {
308308 file : Uri , 
309309 contents : string  |  undefined , 
310310 isInitiallyDirty  =  false , 
311-  trueContents ?: string , 
312311 forVSCodeNotebook ?: boolean 
313312 )  { 
314313 // tslint:disable-next-line: no-any 
@@ -348,18 +347,9 @@ export class NativeEditorStorage implements INotebookStorage {
348347 } 
349348 const  pythonNumber  =  json  ? await  this . extractPythonMainVersion ( json )  : 3 ; 
350349
351-  /* As an optimization, we don't call trustNotebook for hot exit, since our hot exit backup code gets called by VS 
352-  Code whenever the notebook model changes. This means it's called very often, perhaps even as often as autosave. 
353-  Instead, when loading a file that is dirty, we check if the actual file contents on disk are trusted. If so, we treat 
354-  the dirty contents as trusted as well. */ 
355-  const  contentsToCheck  =  isInitiallyDirty  &&  trueContents  !==  undefined  ? trueContents  : contents ; 
356-  const  isTrusted  = 
357-  contents  ===  undefined  ||  isUntitledFile ( file ) 
358-  ? true  // If no contents or untitled, this is a newly created file, so it should be trusted 
359-  : await  this . trustService . isNotebookTrusted ( file ,  contentsToCheck ! ) ; 
360-  return  this . factory . createModel ( 
350+  const  model  =  this . factory . createModel ( 
361351 { 
362-  trusted : isTrusted , 
352+  trusted : true , 
363353 file, 
364354 cells : remapped , 
365355 notebookJson : json , 
@@ -369,6 +359,23 @@ export class NativeEditorStorage implements INotebookStorage {
369359 } , 
370360 forVSCodeNotebook 
371361 ) ; 
362+ 
363+  // If no contents or untitled, this is a newly created file 
364+  // If dirty, that means it's been edited before in our extension 
365+  if  ( contents  !==  undefined  &&  ! isUntitledFile ( file )  &&  ! isInitiallyDirty )  { 
366+  const  isNotebookTrusted  =  await  this . trustService . isNotebookTrusted ( file ,  model . getContent ( ) ) ; 
367+  if  ( isNotebookTrusted  !==  model . isTrusted )  { 
368+  model . update ( { 
369+  source : 'user' , 
370+  kind : 'updateTrust' , 
371+  oldDirty : model . isDirty , 
372+  newDirty : model . isDirty , 
373+  isNotebookTrusted
374+  } ) ; 
375+  } 
376+  } 
377+ 
378+  return  model ; 
372379 } 
373380
374381 private  getStaticStorageKey ( file : Uri ) : string  { 
0 commit comments