Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/client/datascience/interactive-ipynb/nativeEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {

// Sign up for dirty events
model.changed(this.modelChanged.bind(this));
this.previouslyNotTrusted = model.isTrusted;
this.previouslyNotTrusted = !model.isTrusted;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ensures that monitorChangesToTrust tells the UI to update when the user trusts a previously untrusted notebook

}

// tslint:disable-next-line: no-any
Expand Down
33 changes: 20 additions & 13 deletions src/client/datascience/interactive-ipynb/trustCommandHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'use strict';

import { inject, injectable } from 'inversify';
import { Uri } from 'vscode';
import { commands, Uri } from 'vscode';
import { IExtensionSingleActivationService } from '../../activation/types';
import { IApplicationShell, ICommandManager } from '../../common/application/types';
import { ContextKey } from '../../common/contextKey';
Expand Down Expand Up @@ -59,18 +59,25 @@ export class TrustCommandHandler implements IExtensionSingleActivationService {
DataScience.doNotTrustNotebook(),
DataScience.trustAllNotebooks()
);
if (selection !== DataScience.trustNotebook() || model.isTrusted) {
return;

switch (selection) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor selection handling code to explicitly handle each case

case DataScience.trustAllNotebooks():
commands.executeCommand('workbench.action.openSettings', 'python.dataScience.alwaysTrustNotebooks');
break;
case DataScience.trustNotebook():
// Update model trust
model.update({
source: 'user',
kind: 'updateTrust',
oldDirty: model.isDirty,
newDirty: model.isDirty,
isNotebookTrusted: true
});
const contents = model.getContent();
await this.trustService.trustNotebook(model.file, contents);
break;
default:
break;
}
// Update model trust
model.update({
source: 'user',
kind: 'updateTrust',
oldDirty: model.isDirty,
newDirty: model.isDirty,
isNotebookTrusted: true
});
const contents = model.getContent();
await this.trustService.trustNotebook(model.file, contents);
}
}