From 9d752a284983f292e960e3b2b09f1a5a39ad2fb4 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Tue, 22 Oct 2019 11:07:54 -0700 Subject: [PATCH] Include custom editors in history (#83019) Fixes #81824 The history service currently drops any editor input that are not `FileEditorInput`. This does not work for custom editors, which are always backed by a resource but do not subclass `FileEditorInput` The fix here is to create history entries for any input that has a resource that is backed by the file-service --- src/vs/workbench/services/history/browser/history.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/vs/workbench/services/history/browser/history.ts b/src/vs/workbench/services/history/browser/history.ts index a89a7bdd5fc..964c80c9e1a 100644 --- a/src/vs/workbench/services/history/browser/history.ts +++ b/src/vs/workbench/services/history/browser/history.ts @@ -7,7 +7,7 @@ import { onUnexpectedError } from 'vs/base/common/errors'; import { URI, UriComponents } from 'vs/base/common/uri'; import { IEditor } from 'vs/editor/common/editorCommon'; import { ITextEditorOptions, IResourceInput, ITextEditorSelection } from 'vs/platform/editor/common/editor'; -import { IEditorInput, IEditor as IBaseEditor, Extensions as EditorExtensions, EditorInput, IEditorCloseEvent, IEditorInputFactoryRegistry, toResource, Extensions as EditorInputExtensions, IFileInputFactory, IEditorIdentifier } from 'vs/workbench/common/editor'; +import { IEditorInput, IEditor as IBaseEditor, Extensions as EditorExtensions, EditorInput, IEditorCloseEvent, IEditorInputFactoryRegistry, toResource, IEditorIdentifier } from 'vs/workbench/common/editor'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IHistoryService } from 'vs/workbench/services/history/common/history'; import { FileChangesEvent, IFileService, FileChangeType, FILES_EXCLUDE_CONFIG } from 'vs/platform/files/common/files'; @@ -125,8 +125,6 @@ export class HistoryService extends Disposable implements IHistoryService { private loaded: boolean; private resourceFilter: ResourceGlobMatcher; - private fileInputFactory: IFileInputFactory; - private canNavigateBackContextKey: IContextKey; private canNavigateForwardContextKey: IContextKey; private canNavigateToLastEditLocationContextKey: IContextKey; @@ -149,8 +147,6 @@ export class HistoryService extends Disposable implements IHistoryService { this.canNavigateForwardContextKey = (new RawContextKey('canNavigateForward', false)).bindTo(this.contextKeyService); this.canNavigateToLastEditLocationContextKey = (new RawContextKey('canNavigateToLastEditLocation', false)).bindTo(this.contextKeyService); - this.fileInputFactory = Registry.as(EditorInputExtensions.EditorInputFactories).getFileInputFactory(); - this.index = -1; this.lastIndex = -1; this.stack = []; @@ -738,8 +734,9 @@ export class HistoryService extends Disposable implements IHistoryService { } private preferResourceInput(input: IEditorInput): IEditorInput | IResourceInput { - if (this.fileInputFactory.isFileInput(input)) { - return { resource: input.getResource() }; + const resource = input.getResource(); + if (resource && this.fileService.canHandleResource(resource)) { + return { resource: resource }; } return input; -- GitLab