Skip to content

Commit 2103c86

Browse files
authored
Fix regressions in trusted notebooks (#12902)
* Handle trustAllNotebooks selection * Fix bug where after trusting, UI didn't update
1 parent cbe6cdb commit 2103c86

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

src/client/datascience/interactive-ipynb/nativeEditor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
252252

253253
// Sign up for dirty events
254254
model.changed(this.modelChanged.bind(this));
255-
this.previouslyNotTrusted = model.isTrusted;
255+
this.previouslyNotTrusted = !model.isTrusted;
256256
}
257257

258258
// tslint:disable-next-line: no-any

src/client/datascience/interactive-ipynb/trustCommandHandler.ts

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
'use strict';
55

66
import { inject, injectable } from 'inversify';
7-
import { Uri } from 'vscode';
7+
import { commands, Uri } from 'vscode';
88
import { IExtensionSingleActivationService } from '../../activation/types';
99
import { IApplicationShell, ICommandManager } from '../../common/application/types';
1010
import { ContextKey } from '../../common/contextKey';
@@ -57,18 +57,25 @@ export class TrustCommandHandler implements IExtensionSingleActivationService {
5757
DataScience.doNotTrustNotebook(),
5858
DataScience.trustAllNotebooks()
5959
);
60-
if (selection !== DataScience.trustNotebook() || model.isTrusted) {
61-
return;
60+
61+
switch (selection) {
62+
case DataScience.trustAllNotebooks():
63+
commands.executeCommand('workbench.action.openSettings', 'python.dataScience.alwaysTrustNotebooks');
64+
break;
65+
case DataScience.trustNotebook():
66+
// Update model trust
67+
model.update({
68+
source: 'user',
69+
kind: 'updateTrust',
70+
oldDirty: model.isDirty,
71+
newDirty: model.isDirty,
72+
isNotebookTrusted: true
73+
});
74+
const contents = model.getContent();
75+
await this.trustService.trustNotebook(model.file, contents);
76+
break;
77+
default:
78+
break;
6279
}
63-
// Update model trust
64-
model.update({
65-
source: 'user',
66-
kind: 'updateTrust',
67-
oldDirty: model.isDirty,
68-
newDirty: model.isDirty,
69-
isNotebookTrusted: true
70-
});
71-
const contents = model.getContent();
72-
await this.trustService.trustNotebook(model.file, contents);
7380
}
7481
}

0 commit comments

Comments
 (0)