Change:
<!-- Please search existing issues to avoid creating duplicates. --<!-- Also please test using the latest insiders build to make sure your issue has not already been fixed: --<!-- Use Help Report Issue to prefill these. --- VSCode Version: 1.39.2 OS Version: macOS 10.14.3 Steps to Reproduce: the new terminal.newWithCwd command as a new keybinding: to use the new keybinding with an open editor while using VS Code Remote - SSH. Expected Result: New terminal created with the cwd set at ${fileDirname} Actual Result: Error: '${fileDirname}' can not be resolved. Please open an editor. Notes: The keybinding works correctly when working with local directories. The issue only appears over SSH. The Terminal Here extension does work over SSH and accomplishes the same thing, but I would rather use the native feature if possible. The "echo ${fileDirname}" command (run through a task) prints the correct directory over SSH.
is the resolver service being used incorrectly here? seems to resolve fine but not or .
Configuration resolver is owned by hence assigning to him.
that usage seems good. Just make sure you always pass a workspace in. Also note that might be working as expacted ${workspaceFolder} can only be resolved if a folder is opened in VSCode, not in the pruple vscode. ${fileDirname} should always be resolved if there is an open file fyi

Discussion:
public runCommand(accessor: ServicesAccessor, args: { cwd: string } | undefined): Promise<void> { const terminalService = accessor.get(ITerminalService); <del> const configurationResolverService = accessor.get(IConfigurationResolverService); const workspaceContextService = accessor.get(IWorkspaceContextService); const historyService = accessor.get(IHistoryService); const activeWorkspaceRootUri = historyService.getLastActiveWorkspaceRoot(Schemas.file); const lastActiveWorkspaceRoot = activeWorkspaceRootUri ? withNullAsUndefined(workspaceContextService.getWorkspaceFolder(activeWorkspaceRootUri)) : undefined; let cwd: string | undefined; if (args && args.cwd) { cwd = configurationResolverService.resolve(lastActiveWorkspaceRoot, args.cwd); } const instance = terminalService.createTerminal({ cwd }); </del> <ins> const instance = terminalService.createTerminal({ cwd: args?.cwd }); </ins> if (!instance) { return Promise.resolve(undefined); }

logService?: ILogService ): string { if (shell.cwd) { <del> return (typeof shell.cwd === 'object') ? shell.cwd.fsPath : shell.cwd; </del> <ins> const unresolved = (typeof shell.cwd === 'object') ? shell.cwd.fsPath : shell.cwd; const resolved = _resolveCwd(unresolved, lastActiveWorkspace, configurationResolverService); return resolved || unresolved; </ins> } let cwd: string | undefined; if (!shell.ignoreConfigurationCwd && customCwd) { if (configurationResolverService) { <del> try { customCwd = configurationResolverService.resolve(lastActiveWorkspace, customCwd); } catch (e) { // There was an issue resolving a variable, log the error in the console and // fallback to the default. if (logService) { logService.error('Could not resolve terminal.integrated.cwd', e); } customCwd = undefined; } </del> <ins> customCwd = _resolveCwd(customCwd, lastActiveWorkspace, configurationResolverService, logService); </ins> } if (customCwd) { if (path.isAbsolute(customCwd)) {

return _sanitizeCwd(cwd); } <ins> function _resolveCwd(cwd: string, lastActiveWorkspace: IWorkspaceFolder | undefined, configurationResolverService: IConfigurationResolverService | undefined, logService?: ILogService): string | undefined { if (configurationResolverService) { try { return configurationResolverService.resolve(lastActiveWorkspace, cwd); } catch (e) { logService?.error('Could not resolve terminal cwd', e); return undefined; } } return cwd; } </ins> function _sanitizeCwd(cwd: string): string { // Make the drive letter uppercase on Windows (see #9448) if (platform.platform === platform.Platform.Windows && cwd && cwd[1] === ':') {