src/vs/workbench/services/editor/browser/editorService.ts/EditorService/doFindTargetGroup
class EditorService:	private doFindTargetGroup(editor: IEditorInput | IUntypedEditorInput, options?: IEditorOptions, preferredGroup?: OpenInEditorGroup): IEditorGroup {
		let group: IEditorGroup | undefined;

		// Group: Instance of Group
		if (preferredGroup && typeof preferredGroup !== 'number') {
			group = preferredGroup;
		}

		// Group: Side by Side
		else if (preferredGroup === SIDE_GROUP) {
			group = this.findSideBySideGroup();
		}

		// Group: Specific Group
		else if (typeof preferredGroup === 'number' && preferredGroup >= 0) {
			group = this.editorGroupService.getGroup(preferredGroup);
		}

		// Group: Unspecified without a specific index to open
		else if (!options || typeof options.index !== 'number') {
			const groupsByLastActive = this.editorGroupService.getGroups(GroupsOrder.MOST_RECENTLY_ACTIVE);

			// Respect option to reveal an editor if it is already visible in any group
			if (options?.revealIfVisible) {
				for (const lastActiveGroup of groupsByLastActive) {
					if (lastActiveGroup.isActive(editor)) {
						group = lastActiveGroup;
						break;
					}
				}
			}

			// Respect option to reveal an editor if it is open (not necessarily visible)
			// Still prefer to reveal an editor in a group where the editor is active though.
			if (!group) {
				if (options?.revealIfOpened || this.configurationService.getValue<boolean>('workbench.editor.revealIfOpen')) {
					let groupWithInputActive: IEditorGroup | undefined = undefined;
					let groupWithInputOpened: IEditorGroup | undefined = undefined;

					for (const group of groupsByLastActive) {
						if (group.contains(editor)) {
							if (!groupWithInputOpened) {
								groupWithInputOpened = group;
							}

							if (!groupWithInputActive && group.isActive(editor)) {
								groupWithInputActive = group;
							}
						}

						if (groupWithInputOpened && groupWithInputActive) {
							break; // we found all groups we wanted
						}
					}

					// Prefer a target group where the input is visible
					group = groupWithInputActive || groupWithInputOpened;
				}
			}
		}

		// Fallback to active group if target not valid
		if (!group) {
			group = this.editorGroupService.activeGroup;
		}

		return group;
	}