未验证 提交 e0a433b8 编写于 作者: A Andre Weinand 提交者: GitHub

Merge pull request #97440 from bzarco/launch-input-variables

Fix launch configuration input variable resolution.
......@@ -699,8 +699,17 @@ abstract class AbstractLaunch {
if (!config || !config.configurations) {
return undefined;
}
return config.configurations.find(config => config && config.name === name);
const configuration = config.configurations.find(config => config && config.name === name);
if (configuration) {
if (this instanceof UserLaunch) {
configuration.__configurationTarget = ConfigurationTarget.USER;
} else if (this instanceof WorkspaceLaunch) {
configuration.__configurationTarget = ConfigurationTarget.WORKSPACE;
} else {
configuration.__configurationTarget = ConfigurationTarget.WORKSPACE_FOLDER;
}
}
return configuration;
}
async getInitialConfigurationContent(folderUri?: uri, type?: string, token?: CancellationToken): Promise<string> {
......
......@@ -21,7 +21,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
import { IDisposable } from 'vs/base/common/lifecycle';
import { TaskIdentifier } from 'vs/workbench/contrib/tasks/common/tasks';
import { TelemetryService } from 'vs/platform/telemetry/common/telemetryService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { CancellationToken } from 'vs/base/common/cancellation';
import { DebugConfigurationProviderTriggerKind } from 'vs/workbench/api/common/extHostTypes';
import { DebugCompoundRoot } from 'vs/workbench/contrib/debug/common/debugCompoundRoot';
......@@ -538,6 +538,7 @@ export interface IConfig extends IEnvConfig {
linux?: IEnvConfig;
// internals
__configurationTarget?: ConfigurationTarget;
__sessionId?: string;
__restart?: any;
__autoAttach?: boolean;
......
......@@ -108,7 +108,7 @@ export class Debugger implements IDebugger {
substituteVariables(folder: IWorkspaceFolder | undefined, config: IConfig): Promise<IConfig> {
return this.configurationManager.substituteVariables(this.type, folder, config).then(config => {
return this.configurationResolverService.resolveWithInteractionReplace(folder, config, 'launch', this.variables);
return this.configurationResolverService.resolveWithInteractionReplace(folder, config, 'launch', this.variables, config.__configurationTarget);
});
}
......
......@@ -10,7 +10,7 @@ import { Schemas } from 'vs/base/common/network';
import { SideBySideEditor, EditorResourceAccessor } from 'vs/workbench/common/editor';
import { IStringDictionary, forEach, fromMap } from 'vs/base/common/collections';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { IConfigurationService, IConfigurationOverrides, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IWorkspaceFolder, IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
......@@ -146,8 +146,9 @@ export abstract class BaseConfigurationResolverService extends AbstractVariableR
// get all "inputs"
let inputs: ConfiguredInput[] = [];
if (folder && this.workspaceContextService.getWorkbenchState() !== WorkbenchState.EMPTY && section) {
let result = this.configurationService.inspect(section, { resource: folder.uri });
if (this.workspaceContextService.getWorkbenchState() !== WorkbenchState.EMPTY && section) {
const overrides: IConfigurationOverrides = folder ? { resource: folder.uri } : {};
let result = this.configurationService.inspect(section, overrides);
if (result && (result.userValue || result.workspaceValue || result.workspaceFolderValue)) {
switch (target) {
case ConfigurationTarget.USER: inputs = (<any>result.userValue)?.inputs; break;
......@@ -155,7 +156,7 @@ export abstract class BaseConfigurationResolverService extends AbstractVariableR
default: inputs = (<any>result.workspaceFolderValue)?.inputs;
}
} else {
const valueResult = this.configurationService.getValue<any>(section, { resource: folder.uri });
const valueResult = this.configurationService.getValue<any>(section, overrides);
if (valueResult) {
inputs = valueResult.inputs;
}
......
......@@ -448,6 +448,7 @@ suite('Configuration Resolver Service', () => {
assert.equal(1, mockCommandService.callCount);
});
});
test('a single prompt input variable', () => {
const configuration = {
......@@ -475,6 +476,7 @@ suite('Configuration Resolver Service', () => {
assert.equal(0, mockCommandService.callCount);
});
});
test('a single pick input variable', () => {
const configuration = {
......@@ -502,6 +504,7 @@ suite('Configuration Resolver Service', () => {
assert.equal(0, mockCommandService.callCount);
});
});
test('a single command input variable', () => {
const configuration = {
......@@ -529,6 +532,7 @@ suite('Configuration Resolver Service', () => {
assert.equal(1, mockCommandService.callCount);
});
});
test('several input variables and command', () => {
const configuration = {
......@@ -558,6 +562,35 @@ suite('Configuration Resolver Service', () => {
assert.equal(2, mockCommandService.callCount);
});
});
test('input variable with undefined workspace folder', () => {
const configuration = {
'name': 'Attach to Process',
'type': 'node',
'request': 'attach',
'processId': '${input:input1}',
'port': 5858,
'sourceMaps': false,
'outDir': null
};
return configurationResolverService!.resolveWithInteractionReplace(undefined, configuration, 'tasks').then(result => {
assert.deepEqual(result, {
'name': 'Attach to Process',
'type': 'node',
'request': 'attach',
'processId': 'resolvedEnterinput1',
'port': 5858,
'sourceMaps': false,
'outDir': null
});
assert.equal(0, mockCommandService.callCount);
});
});
test('contributed variable', () => {
const buildTask = 'npm: compile';
const variable = 'defaultBuildTask';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册