mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-05 09:35:39 -05:00
Maintain notebook trust status after saving. (#9127)
This commit is contained in:
@@ -19,7 +19,7 @@ import { INotificationService, Severity } from 'vs/platform/notification/common/
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { INotebookService } from 'sql/workbench/services/notebook/browser/notebookService';
|
||||
import { optional } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { getErrorMessage } from 'vs/base/common/errors';
|
||||
import { getErrorMessage, onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { IModelContentChangedEvent } from 'vs/editor/common/model/textModelEvents';
|
||||
import { firstIndex, find } from 'vs/base/common/arrays';
|
||||
@@ -285,7 +285,8 @@ export class CellModel implements ICellModel {
|
||||
|
||||
private notifyExecutionComplete(): void {
|
||||
if (this._notebookService) {
|
||||
this._notebookService.serializeNotebookStateChange(this.notebookModel.notebookUri, NotebookChangeType.CellExecuted, this);
|
||||
this._notebookService.serializeNotebookStateChange(this.notebookModel.notebookUri, NotebookChangeType.CellExecuted, this)
|
||||
.catch(e => onUnexpectedError(e));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorIn
|
||||
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
|
||||
import { BinaryEditorModel } from 'vs/workbench/common/editor/binaryEditorModel';
|
||||
import { NotebookFindModel } from 'sql/workbench/contrib/notebook/find/notebookFindModel';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
|
||||
export type ModeViewSaveHandler = (handle: number) => Thenable<boolean>;
|
||||
|
||||
@@ -160,7 +161,8 @@ export class NotebookEditorModel extends EditorModel {
|
||||
private sendNotebookSerializationStateChange(): void {
|
||||
let notebookModel = this.getNotebookModel();
|
||||
if (notebookModel) {
|
||||
this.notebookService.serializeNotebookStateChange(this.notebookUri, NotebookChangeType.Saved);
|
||||
this.notebookService.serializeNotebookStateChange(this.notebookUri, NotebookChangeType.Saved)
|
||||
.catch(e => onUnexpectedError(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,12 +285,23 @@ export abstract class NotebookInput extends EditorInput {
|
||||
return this._standardKernels;
|
||||
}
|
||||
|
||||
save(groupId: number, options?: ITextFileSaveOptions): Promise<IEditorInput | undefined> {
|
||||
return this.textInput.save(groupId, options);
|
||||
async save(groupId: number, options?: ITextFileSaveOptions): Promise<IEditorInput | undefined> {
|
||||
let input = await this.textInput.save(groupId, options);
|
||||
await this.setTrustForNewEditor(input);
|
||||
return input;
|
||||
}
|
||||
|
||||
saveAs(group: number, options?: ITextFileSaveOptions): Promise<IEditorInput | undefined> {
|
||||
return this.textInput.saveAs(group, options);
|
||||
async saveAs(group: number, options?: ITextFileSaveOptions): Promise<IEditorInput | undefined> {
|
||||
let input = await this.textInput.saveAs(group, options);
|
||||
await this.setTrustForNewEditor(input);
|
||||
return input;
|
||||
}
|
||||
|
||||
private async setTrustForNewEditor(newInput: IEditorInput | undefined): Promise<void> {
|
||||
let isTrusted = this._model.getNotebookModel().trustedMode;
|
||||
if (isTrusted && newInput && newInput.getResource() !== this.getResource()) {
|
||||
await this.notebookService.serializeNotebookStateChange(newInput.getResource(), NotebookChangeType.Saved, undefined, true);
|
||||
}
|
||||
}
|
||||
|
||||
public set standardKernels(value: IStandardKernelWithProvider[]) {
|
||||
|
||||
Reference in New Issue
Block a user