提交 83d8cbea 编写于 作者: B Benjamin Pasero

Revisit file filter usage in quick open (fixes #34958)

上级 e34982ae
......@@ -54,7 +54,7 @@ import { attachQuickOpenStyler } from 'vs/platform/theme/common/styler';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { ITree, IActionProvider } from 'vs/base/parts/tree/browser/tree';
import { BaseActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { FileKind } from 'vs/platform/files/common/files';
import { FileKind, IFileService } from 'vs/platform/files/common/files';
const HELP_PREFIX = '?';
......@@ -1168,7 +1168,8 @@ class EditorHistoryHandler {
constructor(
@IHistoryService private historyService: IHistoryService,
@IInstantiationService private instantiationService: IInstantiationService,
@IWorkspaceContextService private contextService: IWorkspaceContextService
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IFileService private fileService: IFileService
) {
}
......@@ -1189,7 +1190,7 @@ class EditorHistoryHandler {
history.forEach(input => {
let resource: URI;
if (input instanceof EditorInput) {
resource = toResource(input, { filter: ['file', 'untitled'] });
resource = resourceForEditorHistory(input, this.fileService);
} else {
resource = (input as IResourceInput).resource;
}
......@@ -1245,14 +1246,15 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry {
@ITextFileService private textFileService: ITextFileService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IConfigurationService private configurationService: IConfigurationService,
@IEnvironmentService environmentService: IEnvironmentService
@IEnvironmentService environmentService: IEnvironmentService,
@IFileService private fileService: IFileService
) {
super(editorService);
this.input = input;
if (input instanceof EditorInput) {
this.resource = toResource(input, { filter: ['file', 'untitled'] });
this.resource = resourceForEditorHistory(input, fileService);
this.label = input.getName();
this.description = input.getDescription();
this.dirty = input.isDirty();
......@@ -1317,6 +1319,18 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry {
}
}
function resourceForEditorHistory(input: EditorInput, fileService: IFileService): URI {
const resource = toResource(input);
// For the editor history we only prefer resources that are either untitled or
// can be handled by the file service which indicates they are editable resources.
if (resource && (fileService.canHandleResource(resource) || resource.scheme === 'untitled')) {
return resource;
}
return void 0;
}
export class RemoveFromEditorHistoryAction extends Action {
public static ID = 'workbench.action.removeFromEditorHistory';
......
......@@ -245,12 +245,13 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
// Track closing of pinned editor to support to reopen closed editors
if (event.pinned) {
const file = toResource(event.editor, { filter: 'file' }); // we only support files to reopen
if (file) {
const resource = toResource(event.editor);
const supportsReopen = resource && this.fileService.canHandleResource(resource); // we only support file'ish things to reopen
if (supportsReopen) {
// Remove all inputs matching and add as last recently closed
this.removeFromRecentlyClosedFiles(event.editor);
this.recentlyClosedFiles.push({ resource: file, index: event.index });
this.recentlyClosedFiles.push({ resource, index: event.index });
// Bounding
if (this.recentlyClosedFiles.length > HistoryService.MAX_RECENTLY_CLOSED_EDITORS) {
......@@ -591,9 +592,10 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
}
private preferResourceInput(input: IEditorInput): IEditorInput | IResourceInput {
const file = toResource(input, { filter: 'file' });
if (file) {
return { resource: file };
const resource = toResource(input);
const preferResourceInput = resource && this.fileService.canHandleResource(resource); // file'ish things prefer resources
if (preferResourceInput) {
return { resource };
}
return input;
......@@ -678,9 +680,9 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
}
if (arg2 instanceof EditorInput) {
const file = toResource(arg2, { filter: 'file' });
const resource = toResource(arg2);
return file && file.toString() === resource.toString();
return resource && this.fileService.canHandleResource(resource) && resource.toString() === resource.toString();
}
const resourceInput = arg2 as IResourceInput;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册