From a577d545f1cd1d3b9ec91c25581dbfd74a0ee19b Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 26 Aug 2021 09:08:48 +0200 Subject: [PATCH] Locked groups: inactive tab not revealed in locked group (fix #131520) --- .../services/editor/common/editorGroupFinder.ts | 8 ++++---- .../services/editor/test/browser/editorService.test.ts | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/services/editor/common/editorGroupFinder.ts b/src/vs/workbench/services/editor/common/editorGroupFinder.ts index a020b1e46ca..8d323d9af7e 100644 --- a/src/vs/workbench/services/editor/common/editorGroupFinder.ts +++ b/src/vs/workbench/services/editor/common/editorGroupFinder.ts @@ -163,10 +163,10 @@ function isGroupLockedForEditor(group: IEditorGroup, editor: IEditorInput | IUnt return false; } - if (isActive(group, editor)) { - // special case: the active editor of the locked group - // matches the provided one, so in that case we do not - // want to open the editor in any different group. + if (isOpened(group, editor)) { + // special case: the locked group contains + // the provided editor. in that case we do not want + // to open the editor in any different group. return false; } diff --git a/src/vs/workbench/services/editor/test/browser/editorService.test.ts b/src/vs/workbench/services/editor/test/browser/editorService.test.ts index 23108806713..109d276c833 100644 --- a/src/vs/workbench/services/editor/test/browser/editorService.test.ts +++ b/src/vs/workbench/services/editor/test/browser/editorService.test.ts @@ -199,6 +199,7 @@ suite('EditorService', () => { let input4: IResourceEditorInput = { resource: URI.parse('file://resource4-basics.editor-service-locked-group-tests'), options: { pinned: true } }; let input5: IResourceEditorInput = { resource: URI.parse('file://resource5-basics.editor-service-locked-group-tests'), options: { pinned: true } }; let input6: IResourceEditorInput = { resource: URI.parse('file://resource6-basics.editor-service-locked-group-tests'), options: { pinned: true } }; + let input7: IResourceEditorInput = { resource: URI.parse('file://resource7-basics.editor-service-locked-group-tests'), options: { pinned: true } }; let editor1 = await service.openEditor(input1, { pinned: true }); let editor2 = await service.openEditor(input2, { pinned: true }, SIDE_GROUP); @@ -301,6 +302,14 @@ suite('EditorService', () => { assert.strictEqual(part.count, 4); assert.strictEqual(part.activeGroup, group3); assert.strictEqual(group3.activeEditor?.resource?.toString(), input6.resource.toString()); + + // Will reveal an opened editor in the active locked group + await service.openEditor(input7, { pinned: true }, group3); + await service.openEditor(input6, { pinned: true }); + + assert.strictEqual(part.count, 4); + assert.strictEqual(part.activeGroup, group3); + assert.strictEqual(group3.activeEditor?.resource?.toString(), input6.resource.toString()); }); test('locked groups - workbench.editor.revealIfOpen', async () => {