diff --git a/packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts b/packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts index cb891d55a17dd..bc1f5af9bd82a 100755 --- a/packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts +++ b/packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts @@ -51,6 +51,7 @@ import { DiffService } from '@theia/workspace/lib/browser/diff-service'; import { inject, injectable } from 'inversify'; import { Position } from '@theia/plugin-ext/lib/common/plugin-api-rpc'; import { URI } from 'vscode-uri'; +import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor'; export namespace VscodeCommands { export const OPEN: Command = { @@ -330,6 +331,23 @@ export class PluginVscodeCommandsContribution implements CommandContribution { } }); + commands.registerCommand({ id: 'workbench.action.revertAndCloseActiveEditor' }, { + execute: async () => { + const editor = this.editorManager.currentEditor; + if (editor) { + const monacoEditor = MonacoEditor.getCurrent(this.editorManager); + if (monacoEditor) { + try { + await monacoEditor.document.revert(); + editor.close(); + } catch (error) { + await this.shell.closeWidget(editor.id, { save: false }); + } + } + } + } + }); + /** * TODO: * Keep Open workbench.action.keepEditor