|
3 | 3 | * Licensed under the MIT License. See License.txt in the project root for license information. |
4 | 4 | *--------------------------------------------------------------------------------------------*/ |
5 | 5 |
|
6 | | -import { Registry } from 'vs/platform/registry/common/platform'; |
7 | 6 | import { coalesce, distinct } from 'vs/base/common/arrays'; |
8 | 7 | import { Emitter, Event } from 'vs/base/common/event'; |
9 | 8 | import { Lazy } from 'vs/base/common/lazy'; |
10 | 9 | import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle'; |
11 | 10 | import { basename, extname, isEqual } from 'vs/base/common/resources'; |
12 | 11 | import { URI } from 'vs/base/common/uri'; |
13 | 12 | import { generateUuid } from 'vs/base/common/uuid'; |
| 13 | +import { RedoCommand, UndoCommand } from 'vs/editor/browser/editorExtensions'; |
14 | 14 | import * as nls from 'vs/nls'; |
15 | 15 | import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; |
16 | 16 | import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; |
17 | 17 | import { EditorActivation, IEditorOptions, ITextEditorOptions } from 'vs/platform/editor/common/editor'; |
18 | 18 | import { FileOperation, IFileService } from 'vs/platform/files/common/files'; |
19 | 19 | import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; |
20 | 20 | import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput'; |
| 21 | +import { Registry } from 'vs/platform/registry/common/platform'; |
21 | 22 | import { IStorageService } from 'vs/platform/storage/common/storage'; |
22 | 23 | import * as colorRegistry from 'vs/platform/theme/common/colorRegistry'; |
23 | 24 | import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; |
24 | 25 | import { IWorkbenchContribution } from 'vs/workbench/common/contributions'; |
25 | | -import { EditorInput, EditorOptions, GroupIdentifier, IEditorInput, IEditorPane, IEditorInputFactoryRegistry, Extensions as EditorInputExtensions } from 'vs/workbench/common/editor'; |
| 26 | +import { EditorInput, EditorOptions, Extensions as EditorInputExtensions, GroupIdentifier, IEditorInput, IEditorInputFactoryRegistry, IEditorPane } from 'vs/workbench/common/editor'; |
26 | 27 | import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput'; |
27 | 28 | import { CONTEXT_CUSTOM_EDITORS, CONTEXT_FOCUSED_CUSTOM_EDITOR_IS_EDITABLE, CustomEditorCapabilities, CustomEditorInfo, CustomEditorInfoCollection, CustomEditorPriority, ICustomEditorService } from 'vs/workbench/contrib/customEditor/common/customEditor'; |
28 | 29 | import { CustomEditorModelManager } from 'vs/workbench/contrib/customEditor/common/customEditorModelManager'; |
29 | 30 | import { IWebviewService, webviewHasOwnEditFunctionsContext } from 'vs/workbench/contrib/webview/browser/webview'; |
30 | | -import { CustomEditorAssociation, CustomEditorsAssociations, customEditorsAssociationsSettingId, defaultEditorOverrideEntry } from 'vs/workbench/services/editor/common/editorOpenWith'; |
31 | 31 | import { IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'; |
| 32 | +import { CustomEditorAssociation, CustomEditorsAssociations, customEditorsAssociationsSettingId, defaultEditorOverrideEntry } from 'vs/workbench/services/editor/common/editorOpenWith'; |
32 | 33 | import { ICustomEditorInfo, ICustomEditorViewTypesHandler, IEditorService, IOpenEditorOverride, IOpenEditorOverrideEntry } from 'vs/workbench/services/editor/common/editorService'; |
33 | 34 | import { ContributedCustomEditors, defaultCustomEditor } from '../common/contributedCustomEditors'; |
34 | 35 | import { CustomEditorInput } from './customEditorInput'; |
@@ -80,13 +81,30 @@ export class CustomEditorService extends Disposable implements ICustomEditorServ |
80 | 81 | } |
81 | 82 | })); |
82 | 83 |
|
| 84 | + const PRIORITY = 105; |
| 85 | + this._register(UndoCommand.addImplementation(PRIORITY, () => { |
| 86 | + return this.withActiveCustomEditor(editor => editor.undo()); |
| 87 | + })); |
| 88 | + this._register(RedoCommand.addImplementation(PRIORITY, () => { |
| 89 | + return this.withActiveCustomEditor(editor => editor.redo()); |
| 90 | + })); |
| 91 | + |
83 | 92 | this.updateContexts(); |
84 | 93 | } |
85 | 94 |
|
86 | 95 | getViewTypes(): ICustomEditorInfo[] { |
87 | 96 | return [...this._contributedEditors]; |
88 | 97 | } |
89 | 98 |
|
| 99 | + private withActiveCustomEditor(f: (editor: CustomEditorInput) => void): boolean { |
| 100 | + const activeEditor = this.editorService.activeEditor; |
| 101 | + if (activeEditor instanceof CustomEditorInput) { |
| 102 | + f(activeEditor); |
| 103 | + return true; |
| 104 | + } |
| 105 | + return false; |
| 106 | + } |
| 107 | + |
90 | 108 | public get models() { return this._models; } |
91 | 109 |
|
92 | 110 | public getCustomEditor(viewType: string): CustomEditorInfo | undefined { |
|
0 commit comments