提交 b09f1c43 编写于 作者: D Dirk Baeumer

Fixes #31133: Task output - show the folder in which a task is running #31133

上级 ba4f4db5
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册