Skip to content

Commit

Permalink
fix: allow variable substitutions for ports properties
Browse files Browse the repository at this point in the history
  • Loading branch information
connor4312 committed Nov 2, 2023
1 parent 3562af1 commit 8e70cea
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This changelog records changes to stable releases since 1.50.2. "TBA" changes he
- fix: reuse the webassembly worker across sessions in the debug tree ([#1830](https://github.com/microsoft/vscode-js-debug/issues/1830))
- fix: respect sourceMapResolveLocations in the web extension host ([vscode#196781](https://github.com/microsoft/vscode/issues/196781))
- fix: path diff display in diagnostic tool ([vscode#195891](https://github.com/microsoft/vscode/issues/195891))
- fix: allow variable substitutions for ports properties ([vscode#192014](https://github.com/microsoft/vscode/issues/192014))

## v1.84 (October 2023)

Expand Down
18 changes: 14 additions & 4 deletions src/build/generate-contributions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/
import { JSONSchema6 } from 'json-schema';
import { JSONSchema6, JSONSchema6Definition } from 'json-schema';
import type strings from '../../package.nls.json';
import {
allCommands,
Expand Down Expand Up @@ -361,6 +361,16 @@ const nodeBaseConfigurationAttributes: ConfigurationAttributes<INodeBaseConfigur
},
};

const intOrEvaluated: JSONSchema6Definition[] = [
{
type: 'integer',
},
{
type: 'string',
pattern: '^\\${.*}$',
},
];

/**
* Node attach configuration.
*/
Expand Down Expand Up @@ -418,9 +428,9 @@ const nodeAttachConfig: IDebugger<INodeAttachConfiguration> = {
default: 'localhost',
},
port: {
type: 'number',
description: refString('node.port.description'),
default: 9229,
oneOf: intOrEvaluated,
},
websocketAddress: {
type: 'string',
Expand Down Expand Up @@ -633,7 +643,7 @@ const nodeLaunchConfig: IDebugger<INodeLaunchConfiguration> = {
default: true,
},
attachSimplePort: {
type: 'integer',
oneOf: intOrEvaluated,
description: refString('node.attachSimplePort.description'),
default: 9229,
},
Expand Down Expand Up @@ -753,7 +763,7 @@ const chromiumAttachConfigurationAttributes: ConfigurationAttributes<IChromeAtta
default: 'localhost',
},
port: {
type: 'number',
oneOf: intOrEvaluated,
description: refString('browser.attach.port.description'),
default: 9229,
},
Expand Down
3 changes: 3 additions & 0 deletions src/ui/configuration/chromiumDebugConfigurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ export abstract class ChromiumDebugConfigurationResolver<T extends AnyChromiumCo
}

let config = debugConfiguration as T;
if ('port' in config && typeof config.port === 'string') {
config.port = Number(config.port);
}

if (config.request === 'launch') {
const resolvedDataDir = await this.ensureNoLockfile(config);
Expand Down
9 changes: 8 additions & 1 deletion src/ui/configuration/nodeDebugConfigurationResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class NodeConfigurationResolver extends BaseConfigurationResolver<AnyNode
* @inheritdoc
*/
public async resolveDebugConfigurationWithSubstitutedVariables(
folder: vscode.WorkspaceFolder | undefined,
_folder: vscode.WorkspaceFolder | undefined,
rawConfig: vscode.DebugConfiguration,
): Promise<vscode.DebugConfiguration | undefined> {
const config = rawConfig as AnyNodeConfiguration;
Expand All @@ -66,6 +66,13 @@ export class NodeConfigurationResolver extends BaseConfigurationResolver<AnyNode
await resolveProcessId(this.fsUtils, config);
}

if ('port' in config && typeof config.port === 'string') {
config.port = Number(config.port);
}
if ('attachSimplePort' in config && typeof config.attachSimplePort === 'string') {
config.attachSimplePort = Number(config.attachSimplePort);
}

// check that the cwd is valid to avoid mysterious ENOENTs (vscode#133310)
if (config.cwd) {
const stats = await existsInjected(fs, config.cwd);
Expand Down

0 comments on commit 8e70cea

Please sign in to comment.