UNPKG

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

Version:

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

44 lines (40 loc) 2.44 kB
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6'; import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls'; import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation'; import { extHostCustomer } from '../../services/extensions/common/extHostCustomers.js'; import { ExtHostContext } from '@codingame/monaco-vscode-api/vscode/vs/workbench/api/common/extHost.protocol'; import { raceCancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async'; import { IWorkingCopyFileService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/workingCopy/common/workingCopyFileService.service'; import { NotebookFileWorkingCopyModel } from '@codingame/monaco-vscode-api/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(2637, "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 };