src/vs/workbench/contrib/search/browser/search.contribution.ts/searchInFolderCommand
const searchInFolderCommand: ICommandHandler = async (accessor, resource?: URI) => {
	const listService = accessor.get(IListService);
	const fileService = accessor.get(IFileService);
	const viewsService = accessor.get(IViewsService);
	const contextService = accessor.get(IWorkspaceContextService);
	const commandService = accessor.get(ICommandService);
	const resources = getMultiSelectedResources(resource, listService, accessor.get(IEditorService), accessor.get(IExplorerService));
	const searchConfig = accessor.get(IConfigurationService).getValue<ISearchConfiguration>().search;
	const mode = searchConfig.mode;

	const resolvedResources = fileService.resolveAll(resources.map(resource => ({ resource }))).then(results => {
		const folders: URI[] = [];
		results.forEach(result => {
			if (result.success && result.stat) {
				folders.push(result.stat.isDirectory ? result.stat.resource : dirname(result.stat.resource));
			}
		});
		return resolveResourcesForSearchIncludes(folders, contextService);
	});

	if (mode === 'view') {
		const searchView = await openSearchView(viewsService, true);
		if (resources && resources.length && searchView) {
			searchView.searchInFolders(await resolvedResources);
		}
		return undefined;
	} else {
		return commandService.executeCommand(SearchEditorConstants.OpenEditorCommandId, {
			filesToInclude: (await resolvedResources).join(', '),
			showIncludesExcludes: true,
			location: mode === 'newEditor' ? 'new' : 'reuse',
		});
	}
};