Make sure custom editors still correctly override webview undo/redo
For #90110
This commit is contained in:
parent
593ee445cf
commit
688b97d811
|
@ -3,7 +3,6 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { coalesce, distinct } from 'vs/base/common/arrays';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { Lazy } from 'vs/base/common/lazy';
|
||||
|
@ -11,6 +10,7 @@ import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle'
|
|||
import { basename, extname, isEqual } from 'vs/base/common/resources';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { RedoCommand, UndoCommand } from 'vs/editor/browser/editorExtensions';
|
||||
import * as nls from 'vs/nls';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
@ -18,17 +18,18 @@ import { EditorActivation, IEditorOptions, ITextEditorOptions } from 'vs/platfor
|
|||
import { FileOperation, IFileService } from 'vs/platform/files/common/files';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import * as colorRegistry from 'vs/platform/theme/common/colorRegistry';
|
||||
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||
import { EditorInput, EditorOptions, GroupIdentifier, IEditorInput, IEditorPane, IEditorInputFactoryRegistry, Extensions as EditorInputExtensions } from 'vs/workbench/common/editor';
|
||||
import { EditorInput, EditorOptions, Extensions as EditorInputExtensions, GroupIdentifier, IEditorInput, IEditorInputFactoryRegistry, IEditorPane } from 'vs/workbench/common/editor';
|
||||
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
|
||||
import { CONTEXT_CUSTOM_EDITORS, CONTEXT_FOCUSED_CUSTOM_EDITOR_IS_EDITABLE, CustomEditorCapabilities, CustomEditorInfo, CustomEditorInfoCollection, CustomEditorPriority, ICustomEditorService } from 'vs/workbench/contrib/customEditor/common/customEditor';
|
||||
import { CustomEditorModelManager } from 'vs/workbench/contrib/customEditor/common/customEditorModelManager';
|
||||
import { IWebviewService, webviewHasOwnEditFunctionsContext } from 'vs/workbench/contrib/webview/browser/webview';
|
||||
import { CustomEditorAssociation, CustomEditorsAssociations, customEditorsAssociationsSettingId, defaultEditorOverrideEntry } from 'vs/workbench/services/editor/common/editorOpenWith';
|
||||
import { IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { CustomEditorAssociation, CustomEditorsAssociations, customEditorsAssociationsSettingId, defaultEditorOverrideEntry } from 'vs/workbench/services/editor/common/editorOpenWith';
|
||||
import { ICustomEditorInfo, ICustomEditorViewTypesHandler, IEditorService, IOpenEditorOverride, IOpenEditorOverrideEntry } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { ContributedCustomEditors, defaultCustomEditor } from '../common/contributedCustomEditors';
|
||||
import { CustomEditorInput } from './customEditorInput';
|
||||
|
@ -80,6 +81,14 @@ export class CustomEditorService extends Disposable implements ICustomEditorServ
|
|||
}
|
||||
}));
|
||||
|
||||
const PRIORITY = 105;
|
||||
this._register(UndoCommand.addImplementation(PRIORITY, () => {
|
||||
return this.withActiveCustomEditor(editor => editor.undo());
|
||||
}));
|
||||
this._register(RedoCommand.addImplementation(PRIORITY, () => {
|
||||
return this.withActiveCustomEditor(editor => editor.redo());
|
||||
}));
|
||||
|
||||
this.updateContexts();
|
||||
}
|
||||
|
||||
|
@ -87,6 +96,15 @@ export class CustomEditorService extends Disposable implements ICustomEditorServ
|
|||
return [...this._contributedEditors];
|
||||
}
|
||||
|
||||
private withActiveCustomEditor(f: (editor: CustomEditorInput) => void): boolean {
|
||||
const activeEditor = this.editorService.activeEditor;
|
||||
if (activeEditor instanceof CustomEditorInput) {
|
||||
f(activeEditor);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public get models() { return this._models; }
|
||||
|
||||
public getCustomEditor(viewType: string): CustomEditorInfo | undefined {
|
||||
|
|
Loading…
Reference in a new issue