|
4 | 4 | *--------------------------------------------------------------------------------------------*/ |
5 | 5 |
|
6 | 6 | import * as assert from 'assert'; |
| 7 | +import { Event } from 'vs/base/common/event'; |
7 | 8 | import { workbenchInstantiationService, registerTestEditor, TestFileEditorInput, TestEditorPart, ITestInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices'; |
8 | | -import { GroupDirection, GroupsOrder, MergeGroupMode, GroupOrientation, GroupChangeKind, GroupLocation } from 'vs/workbench/services/editor/common/editorGroupsService'; |
| 9 | +import { GroupDirection, GroupsOrder, MergeGroupMode, GroupOrientation, GroupChangeKind, GroupLocation, OpenEditorContext } from 'vs/workbench/services/editor/common/editorGroupsService'; |
9 | 10 | import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; |
10 | 11 | import { EditorOptions, CloseDirection, IEditorPartOptions, EditorsOrder } from 'vs/workbench/common/editor'; |
11 | 12 | import { URI } from 'vs/base/common/uri'; |
@@ -1031,4 +1032,49 @@ suite('EditorGroupsService', () => { |
1031 | 1032 | editorGroupChangeListener.dispose(); |
1032 | 1033 | part.dispose(); |
1033 | 1034 | }); |
| 1035 | + |
| 1036 | + test('moveEditor with context (across groups)', async () => { |
| 1037 | + const [part] = createPart(); |
| 1038 | + const group = part.activeGroup; |
| 1039 | + assert.equal(group.isEmpty, true); |
| 1040 | + |
| 1041 | + const rightGroup = part.addGroup(group, GroupDirection.RIGHT); |
| 1042 | + |
| 1043 | + const input = new TestFileEditorInput(URI.file('foo/bar'), TEST_EDITOR_INPUT_ID); |
| 1044 | + const inputInactive = new TestFileEditorInput(URI.file('foo/bar/inactive'), TEST_EDITOR_INPUT_ID); |
| 1045 | + let firstOpenEditorContext: OpenEditorContext | undefined; |
| 1046 | + Event.once(group.onWillOpenEditor)(e => { |
| 1047 | + firstOpenEditorContext = e.context; |
| 1048 | + }); |
| 1049 | + await group.openEditors([{ editor: input, options: { pinned: true } }, { editor: inputInactive }]); |
| 1050 | + assert.equal(firstOpenEditorContext, undefined); |
| 1051 | + |
| 1052 | + const waitForEditorWillOpen = new Promise<OpenEditorContext | undefined>(c => { |
| 1053 | + Event.once(rightGroup.onWillOpenEditor)(e => c(e.context)); |
| 1054 | + }); |
| 1055 | + |
| 1056 | + group.moveEditor(inputInactive, rightGroup, { index: 0 }); |
| 1057 | + const context = await waitForEditorWillOpen; |
| 1058 | + assert.equal(context, OpenEditorContext.MOVE_EDITOR); |
| 1059 | + part.dispose(); |
| 1060 | + }); |
| 1061 | + |
| 1062 | + test('copyEditor with context (across groups)', async () => { |
| 1063 | + const [part] = createPart(); |
| 1064 | + const group = part.activeGroup; |
| 1065 | + assert.equal(group.isEmpty, true); |
| 1066 | + |
| 1067 | + const rightGroup = part.addGroup(group, GroupDirection.RIGHT); |
| 1068 | + const input = new TestFileEditorInput(URI.file('foo/bar'), TEST_EDITOR_INPUT_ID); |
| 1069 | + const inputInactive = new TestFileEditorInput(URI.file('foo/bar/inactive'), TEST_EDITOR_INPUT_ID); |
| 1070 | + await group.openEditors([{ editor: input, options: { pinned: true } }, { editor: inputInactive }]); |
| 1071 | + const waitForEditorWillOpen = new Promise<OpenEditorContext | undefined>(c => { |
| 1072 | + Event.once(rightGroup.onWillOpenEditor)(e => c(e.context)); |
| 1073 | + }); |
| 1074 | + |
| 1075 | + group.copyEditor(inputInactive, rightGroup, { index: 0 }); |
| 1076 | + const context = await waitForEditorWillOpen; |
| 1077 | + assert.equal(context, OpenEditorContext.COPY_EDITOR); |
| 1078 | + part.dispose(); |
| 1079 | + }); |
1034 | 1080 | }); |
0 commit comments