UNPKG

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

Version:

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

46 lines (43 loc) 2.22 kB
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js'; import { shouldSynchronizeModel } from 'vscode/vscode/vs/editor/common/model'; 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 { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles.service'; import { ExtHostContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol'; import { raceCancellationError } from 'vscode/vscode/vs/base/common/async'; class ExtHostSaveParticipant { constructor(extHostContext) { this._proxy = ( (extHostContext.getProxy(ExtHostContext.ExtHostDocumentSaveParticipant))); } async participate(editorModel, context, _progress, token) { if (!editorModel.textEditorModel || !shouldSynchronizeModel(editorModel.textEditorModel)) { return undefined; } const p = ( (new Promise((resolve, reject) => { setTimeout(() => reject(( (new Error(( localize(4864, "Aborted onWillSaveTextDocument-event after 1750ms")))))), 1750); this._proxy.$participateInSave(editorModel.resource, context.reason).then(values => { if (!values.every(success => success)) { return Promise.reject(( (new Error('listener failed')))); } return undefined; }).then(resolve, reject); }))); return raceCancellationError(p, token); } } let SaveParticipant = class SaveParticipant { constructor(extHostContext, instantiationService, _textFileService) { this._textFileService = _textFileService; this._saveParticipantDisposable = this._textFileService.files.addSaveParticipant(instantiationService.createInstance(ExtHostSaveParticipant, extHostContext)); } dispose() { this._saveParticipantDisposable.dispose(); } }; SaveParticipant = __decorate([ extHostCustomer, ( (__param(1, IInstantiationService))), ( (__param(2, ITextFileService))) ], SaveParticipant); export { SaveParticipant };