UNPKG

@codingame/monaco-vscode-extensions-service-override

Version:

VSCode public API plugged on the monaco editor - extensions service-override

45 lines (42 loc) 2.29 kB
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js'; import { localize } from 'vscode/vscode/vs/nls'; import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation'; import { extHostCustomer } from '../../services/extensions/common/extHostCustomers.js'; import { ExtHostContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol'; import { raceCancellationError } from 'vscode/vscode/vs/base/common/async'; import { IWorkingCopyFileService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyFileService.service'; import { NotebookFileWorkingCopyModel } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookEditorModel'; class ExtHostNotebookDocumentSaveParticipant { constructor(extHostContext) { this._proxy = ( (extHostContext.getProxy(ExtHostContext.ExtHostNotebookDocumentSaveParticipant))); } async participate(workingCopy, context, _progress, token) { if (!workingCopy.model || !(workingCopy.model instanceof NotebookFileWorkingCopyModel)) { return undefined; } let _warningTimeout; const p = ( (new Promise((resolve, reject) => { _warningTimeout = setTimeout(() => reject(( (new Error(( localize(4874, "Aborted onWillSaveNotebookDocument-event after 1750ms")))))), 1750); this._proxy.$participateInSave(workingCopy.resource, context.reason, token).then(_ => { clearTimeout(_warningTimeout); return undefined; }).then(resolve, reject); }))); return raceCancellationError(p, token); } } let SaveParticipant = class SaveParticipant { constructor(extHostContext, instantiationService, workingCopyFileService) { this.workingCopyFileService = workingCopyFileService; this._saveParticipantDisposable = this.workingCopyFileService.addSaveParticipant(instantiationService.createInstance(ExtHostNotebookDocumentSaveParticipant, extHostContext)); } dispose() { this._saveParticipantDisposable.dispose(); } }; SaveParticipant = __decorate([ extHostCustomer, ( (__param(1, IInstantiationService))), ( (__param(2, IWorkingCopyFileService))) ], SaveParticipant); export { SaveParticipant };