extensions/typescript-language-features/src/ui/jsNodeWalkthrough.electron.ts/tryDebugRelevantDocument
async function tryDebugRelevantDocument(lastDocument: vscode.TextDocument | undefined, languageId: string, languageExtensions: [string, ...string[]], createFileAndFocus: () => Promise<vscode.TextEditor>): Promise<void> {
	let searchResult!: DocSearchResult;
	for (const languageExtension of languageExtensions) {
		searchResult = tryFindRelevantDocument(lastDocument, languageId, languageExtension);
		if (searchResult.kind !== 'not-found') {
			break;
		}
	}

	let editor: vscode.TextEditor;
	// If not, make one.
	switch (searchResult.kind) {
		case 'visible':
			// Focus if necessary.
			editor = searchResult.editor;
			if (vscode.window.activeTextEditor !== editor) {
				await vscode.window.showTextDocument(editor.document, {
					viewColumn: vscode.ViewColumn.Beside,
				});
			}
			break;
		case 'hidden':
			editor = await vscode.window.showTextDocument(searchResult.uri, {
				viewColumn: vscode.ViewColumn.Beside,
			});
			break;
		case 'not-found':
			editor = await createFileAndFocus();
			break;
	}

	await Promise.all([
		vscode.commands.executeCommand('workbench.action.debug.start'),
		vscode.commands.executeCommand('workbench.debug.action.focusRepl'),
	]);

}