Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2 Fixes/10597.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure default `host` is not set, if `connect` or `listen` settings are available.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ export class AttachConfigurationResolver extends BaseConfigurationResolver<Attac
if (!Array.isArray(debugConfiguration.debugOptions)) {
debugConfiguration.debugOptions = [];
}
if (!debugConfiguration.host) {
if (!(debugConfiguration.connect || debugConfiguration.listen) && !debugConfiguration.host) {
// Connect and listen cannot be mixed with host property.
debugConfiguration.host = 'localhost';
}
if (debugConfiguration.justMyCode === undefined) {
Expand Down Expand Up @@ -116,7 +117,7 @@ export class AttachConfigurationResolver extends BaseConfigurationResolver<Attac

private resolvePathMappings(
pathMappings: PathMapping[],
host: string,
host?: string,
localRoot?: string,
remoteRoot?: string,
workspaceFolder?: Uri
Expand Down
7 changes: 7 additions & 0 deletions src/client/debugger/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export type PathMapping = {
localRoot: string;
remoteRoot: string;
};
export type Connection = {
host: string;
port: number;
};

interface ICommonDebugArguments {
redirectOutput?: boolean;
django?: boolean;
Expand Down Expand Up @@ -54,6 +59,8 @@ export interface IKnownAttachDebugArguments extends ICommonDebugArguments {
subProcessId?: number;

processId?: number | string;
connect?: Connection;
listen?: Connection;
}

export interface IKnownLaunchRequestArguments extends ICommonDebugArguments {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,32 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
.deep.equal(debugOptionsAvailable);
expect(debugConfig).to.have.property('host', 'localhost');
});
test('Default host should not be added if connect is available.', async () => {
const pythonFile = 'xyz.py';

setupActiveEditor(pythonFile, PYTHON_LANGUAGE);
setupWorkspaces([]);

const debugConfig = await debugProvider.resolveDebugConfiguration!(undefined, {
request: 'attach',
connect: { host: 'localhost', port: 5678 }
} as AttachRequestArguments);

expect(debugConfig).to.not.have.property('host', 'localhost');
});
test('Default host should not be added if listen is available.', async () => {
const pythonFile = 'xyz.py';

setupActiveEditor(pythonFile, PYTHON_LANGUAGE);
setupWorkspaces([]);

const debugConfig = await debugProvider.resolveDebugConfiguration!(undefined, {
request: 'attach',
listen: { host: 'localhost', port: 5678 }
} as AttachRequestArguments);

expect(debugConfig).to.not.have.property('host', 'localhost');
});
test("Ensure 'localRoot' is left unaltered", async () => {
const activeFile = 'xyz.py';
const workspaceFolder = createMoqWorkspaceFolder(__dirname);
Expand Down