提交 36bf554a 编写于 作者: B Benjamin Pasero

fix #16223

上级 fe4e29b3
......@@ -16,10 +16,12 @@ import { IBackupService, IBackupFileService } from 'vs/workbench/services/backup
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { ITextModelResolverService } from 'vs/editor/common/services/resolverService';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { Position } from 'vs/platform/editor/common/editor';
import { Position, IEditorInput } from 'vs/platform/editor/common/editor';
export class BackupRestorer implements IWorkbenchContribution {
private static readonly UNTITLED_REGEX = /Untitled-\d+/;
constructor(
@IUntitledEditorService private untitledEditorService: IUntitledEditorService,
@IEnvironmentService private environmentService: IEnvironmentService,
......@@ -61,7 +63,7 @@ export class BackupRestorer implements IWorkbenchContribution {
const stacks = this.groupService.getStacksModel();
const hasOpenedEditors = stacks.groups.length > 0;
return TPromise.join(inputs.map(resource => this.editorService.createInput({ resource }))).then(inputs => {
return TPromise.join(inputs.map(resource => this.createInput(resource))).then(inputs => {
const openEditorsArgs = inputs.map((input, index) => {
return { input, options: { pinned: true, preserveFocus: true, inactive: index > 0 || hasOpenedEditors }, position: Position.ONE };
});
......@@ -71,6 +73,16 @@ export class BackupRestorer implements IWorkbenchContribution {
});
}
private createInput(resource: URI): TPromise<IEditorInput> {
if (resource.scheme === 'untitled' && !BackupRestorer.UNTITLED_REGEX.test(resource.fsPath)) {
// TODO@Ben debt: instead of guessing if an untitled file has an associated file path or not
// this information should be provided by the backup service and stored as meta data within
return TPromise.as(this.untitledEditorService.createOrGet(URI.file(resource.fsPath)));
}
return this.editorService.createInput({ resource });
}
private doResolveOpenedBackups(backups: URI[]): TPromise<URI[]> {
const stacks = this.groupService.getStacksModel();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册