mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
This commit is contained in:
parent
23850e2363
commit
9170aa877c
|
@ -106,26 +106,6 @@ export class MainThreadCustomEditors extends Disposable implements extHostProtoc
|
||||||
|
|
||||||
// Working copy operations
|
// Working copy operations
|
||||||
this._register(workingCopyFileService.onWillRunWorkingCopyFileOperation(async e => this.onWillRunWorkingCopyFileOperation(e)));
|
this._register(workingCopyFileService.onWillRunWorkingCopyFileOperation(async e => this.onWillRunWorkingCopyFileOperation(e)));
|
||||||
|
|
||||||
this._register(extensionService.onWillStop(e => {
|
|
||||||
const dirtyCustomEditors = workingCopyService.workingCopies.filter(workingCopy => {
|
|
||||||
return workingCopy instanceof MainThreadCustomEditorModel && workingCopy.isDirty();
|
|
||||||
});
|
|
||||||
if (!dirtyCustomEditors.length) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
e.veto((async () => {
|
|
||||||
for (const dirtyCustomEditor of dirtyCustomEditors) {
|
|
||||||
const didSave = await dirtyCustomEditor.save();
|
|
||||||
if (!didSave) {
|
|
||||||
// Veto
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false; // Don't veto
|
|
||||||
})(), localize('vetoExtHostRestart', "One or more custom editors could not be saved."));
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public $registerTextEditorProvider(extensionData: extHostProtocol.WebviewExtensionDescription, viewType: string, options: extHostProtocol.IWebviewPanelOptions, capabilities: extHostProtocol.CustomTextEditorCapabilities, serializeBuffersForPostMessage: boolean): void {
|
public $registerTextEditorProvider(extensionData: extHostProtocol.WebviewExtensionDescription, viewType: string, options: extHostProtocol.IWebviewPanelOptions, capabilities: extHostProtocol.CustomTextEditorCapabilities, serializeBuffersForPostMessage: boolean): void {
|
||||||
|
@ -399,6 +379,7 @@ class MainThreadCustomEditorModel extends ResourceWorkingCopy implements ICustom
|
||||||
@IWorkbenchEnvironmentService private readonly _environmentService: IWorkbenchEnvironmentService,
|
@IWorkbenchEnvironmentService private readonly _environmentService: IWorkbenchEnvironmentService,
|
||||||
@IWorkingCopyService workingCopyService: IWorkingCopyService,
|
@IWorkingCopyService workingCopyService: IWorkingCopyService,
|
||||||
@IPathService private readonly _pathService: IPathService,
|
@IPathService private readonly _pathService: IPathService,
|
||||||
|
@IExtensionService extensionService: IExtensionService,
|
||||||
) {
|
) {
|
||||||
super(MainThreadCustomEditorModel.toWorkingCopyResource(_viewType, _editorResource), fileService);
|
super(MainThreadCustomEditorModel.toWorkingCopyResource(_viewType, _editorResource), fileService);
|
||||||
|
|
||||||
|
@ -406,6 +387,21 @@ class MainThreadCustomEditorModel extends ResourceWorkingCopy implements ICustom
|
||||||
|
|
||||||
if (_editable) {
|
if (_editable) {
|
||||||
this._register(workingCopyService.registerWorkingCopy(this));
|
this._register(workingCopyService.registerWorkingCopy(this));
|
||||||
|
|
||||||
|
this._register(extensionService.onWillStop(e => {
|
||||||
|
if (!this.isDirty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
e.veto((async () => {
|
||||||
|
const didSave = await this.save();
|
||||||
|
if (!didSave) {
|
||||||
|
// Veto
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false; // Don't veto
|
||||||
|
})(), localize('vetoExtHostRestart', "Custom editor '{0}' could not be saved.", this.name));
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normally means we're re-opening an untitled file
|
// Normally means we're re-opening an untitled file
|
||||||
|
|
|
@ -70,7 +70,7 @@ export class SimpleNotebookEditorModel extends EditorModel implements INotebookE
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false; // Don't veto
|
return false; // Don't veto
|
||||||
})(), localize('vetoExtHostRestart', "Notebook could not be saved."));
|
})(), localize('vetoExtHostRestart', "Notebook '{0}' could not be saved.", this._workingCopy?.name));
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue