From 5d37bb76cd1c583332fb3f350f064b07b029e92a Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Tue, 12 May 2020 10:42:09 +0200 Subject: [PATCH] better fix for #97584 without flicker --- .../services/history/browser/history.ts | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/vs/workbench/services/history/browser/history.ts b/src/vs/workbench/services/history/browser/history.ts index 98c0db273d7..58a51270185 100644 --- a/src/vs/workbench/services/history/browser/history.ts +++ b/src/vs/workbench/services/history/browser/history.ts @@ -5,7 +5,7 @@ import { URI, UriComponents } from 'vs/base/common/uri'; import { IEditor } from 'vs/editor/common/editorCommon'; -import { ITextEditorOptions, IResourceEditorInput, TextEditorSelectionRevealType } from 'vs/platform/editor/common/editor'; +import { ITextEditorOptions, IResourceEditorInput, TextEditorSelectionRevealType, IEditorOptions } from 'vs/platform/editor/common/editor'; import { IEditorInput, IEditorPane, Extensions as EditorExtensions, EditorInput, IEditorCloseEvent, IEditorInputFactoryRegistry, toResource, IEditorIdentifier, GroupIdentifier, EditorsOrder } from 'vs/workbench/common/editor'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IHistoryService } from 'vs/workbench/services/history/common/history'; @@ -638,23 +638,23 @@ export class HistoryService extends Disposable implements IHistoryService { if (lastClosedFile) { (async () => { - const editor = await this.editorService.openEditor({ - resource: lastClosedFile.resource, - options: { - pinned: true, - sticky: lastClosedFile.sticky, - index: lastClosedFile.index - } - }); - - // Make the editor sticky after opening it. Even though we provide - // the sticky option, the editor service may decide to not respect - // the flag given there is also an index provided which maybe outside - // of the sticky range + let options: IEditorOptions; if (lastClosedFile.sticky) { - editor?.group?.stickEditor(editor.input); + // Sticky: in case the target index is outside of the range of + // sticky editors, we make sure to not provide the index as + // option. Otherwise the index will cause the sticky flag to + // be ignored. + if (!this.editorGroupService.activeGroup.isSticky(lastClosedFile.index)) { + options = { pinned: true, sticky: true }; + } else { + options = { pinned: true, sticky: true, index: lastClosedFile.index }; + } + } else { + options = { pinned: true, index: lastClosedFile.index }; } + const editor = await this.editorService.openEditor({ resource: lastClosedFile.resource, options }); + // Fix for https://github.com/Microsoft/vscode/issues/67882 // If opening of the editor fails, make sure to try the next one // but make sure to remove this one from the list to prevent -- GitLab