提交 afb94f4e 编写于 作者: B Benjamin Pasero

Launching Code to edit a file with an unsaved file from prior hot exit focuses...

Launching Code to edit a file with an unsaved file from prior hot exit focuses incorrect file on start (fixes #26973)
上级 9b63b6be
......@@ -83,26 +83,25 @@ export class BackupRestorer implements IWorkbenchContribution {
private doOpenEditors(resources: URI[]): TPromise<void> {
const stacks = this.groupService.getStacksModel();
const hasOpenedEditors = stacks.groups.length > 0;
const inputs = resources.map(resource => this.resolveInput(resource));
const openEditorsArgs = inputs.map((input, index) => {
return { input, options: { pinned: true, preserveFocus: true, inactive: index > 0 || hasOpenedEditors }, position: Position.ONE };
});
const inputs = resources.map((resource, index) => this.resolveInput(resource, index, hasOpenedEditors));
// Open all remaining backups as editors and resolve them to load their backups
return this.editorService.openEditors(openEditorsArgs).then(() => void 0);
return this.editorService.openEditors(inputs.map(input => { return { input, position: Position.ONE }; })).then(() => void 0);
}
private resolveInput(resource: URI): IResourceInput | IUntitledResourceInput {
private resolveInput(resource: URI, index: number, hasOpenedEditors: boolean): IResourceInput | IUntitledResourceInput {
const options = { pinned: true, preserveFocus: true, inactive: index > 0 || hasOpenedEditors };
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 { filePath: resource.fsPath };
return { filePath: resource.fsPath, options };
}
return { resource };
return { resource, options };
}
public getId(): string {
return 'vs.backup.backupRestorer';
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册