未验证 提交 9d752a28 编写于 作者: M Matt Bierner 提交者: GitHub

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
上级 a18e992b
......@@ -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<boolean>;
private canNavigateForwardContextKey: IContextKey<boolean>;
private canNavigateToLastEditLocationContextKey: IContextKey<boolean>;
......@@ -149,8 +147,6 @@ export class HistoryService extends Disposable implements IHistoryService {
this.canNavigateForwardContextKey = (new RawContextKey<boolean>('canNavigateForward', false)).bindTo(this.contextKeyService);
this.canNavigateToLastEditLocationContextKey = (new RawContextKey<boolean>('canNavigateToLastEditLocation', false)).bindTo(this.contextKeyService);
this.fileInputFactory = Registry.as<IEditorInputFactoryRegistry>(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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册