From b09f1c4358e1cbb8789d908420436df5db65dbe4 Mon Sep 17 00:00:00 2001 From: Dirk Baeumer Date: Thu, 21 Sep 2017 16:38:11 +0200 Subject: [PATCH] Fixes #31133: Task output - show the folder in which a task is running #31133 --- .../tasks/electron-browser/terminalTaskSystem.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/parts/tasks/electron-browser/terminalTaskSystem.ts b/src/vs/workbench/parts/tasks/electron-browser/terminalTaskSystem.ts index 1176ca1c7af..39b6e37ba07 100644 --- a/src/vs/workbench/parts/tasks/electron-browser/terminalTaskSystem.ts +++ b/src/vs/workbench/parts/tasks/electron-browser/terminalTaskSystem.ts @@ -22,7 +22,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import * as TPath from 'vs/base/common/paths'; import { IMarkerService } from 'vs/platform/markers/common/markers'; -import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; +import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace'; import { IModelService } from 'vs/editor/common/services/modelService'; import { ProblemMatcher, ProblemMatcherRegistry /*, ProblemPattern, getResource */ } from 'vs/platform/markers/common/problemMatcher'; @@ -440,6 +440,8 @@ export class TerminalTaskSystem extends EventEmitter implements ITaskSystem { }; let shellLaunchConfig: IShellLaunchConfig = undefined; let isShellCommand = task.command.runtime === RuntimeType.Shell; + let workspaceFolder = Task.getWorkspaceFolder(task); + let needsFolderQualification = workspaceFolder && this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE; if (isShellCommand) { if (Platform.isWindows && ((options.cwd && TPath.isUNC(options.cwd)) || (!options.cwd && TPath.isUNC(process.cwd())))) { throw new TaskError(Severity.Error, nls.localize('TerminalTaskSystem', 'Can\'t execute a shell command on an UNC drive.'), TaskErrors.UnknownError); @@ -492,7 +494,11 @@ export class TerminalTaskSystem extends EventEmitter implements ITaskSystem { shellArgs.push(commandLine); shellLaunchConfig.args = windowsShellArgs ? shellArgs.join(' ') : shellArgs; if (task.command.presentation.echo) { - shellLaunchConfig.initialText = `\x1b[1m> Executing task: ${commandLine} <\x1b[0m\n`; + if (needsFolderQualification) { + shellLaunchConfig.initialText = `\x1b[1m> Executing task in folder ${workspaceFolder.name}: ${commandLine} <\x1b[0m\n`; + } else { + shellLaunchConfig.initialText = `\x1b[1m> Executing task: ${commandLine} <\x1b[0m\n`; + } } } else { let cwd = options && options.cwd ? options.cwd : process.cwd(); @@ -515,7 +521,11 @@ export class TerminalTaskSystem extends EventEmitter implements ITaskSystem { } return args.join(' '); }; - shellLaunchConfig.initialText = `\x1b[1m> Executing task: ${shellLaunchConfig.executable} ${getArgsToEcho(shellLaunchConfig.args)} <\x1b[0m\n`; + if (needsFolderQualification) { + shellLaunchConfig.initialText = `\x1b[1m> Executing task in folder ${workspaceFolder.name}: ${shellLaunchConfig.executable} ${getArgsToEcho(shellLaunchConfig.args)} <\x1b[0m\n`; + } else { + shellLaunchConfig.initialText = `\x1b[1m> Executing task: ${shellLaunchConfig.executable} ${getArgsToEcho(shellLaunchConfig.args)} <\x1b[0m\n`; + } } } if (options.cwd) { -- GitLab