Skip to content

Commit ed8d053

Browse files
authored
respect existing serverReadyAction in launch config (#646)
1 parent 6b1f3a3 commit ed8d053

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/extension/debugger/configuration/resolvers/launch.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@ export class LaunchConfigurationResolver extends BaseConfigurationResolver<Launc
146146
}
147147
const isFastAPI = LaunchConfigurationResolver.isDebuggingFastAPI(debugConfiguration);
148148
const isFlask = LaunchConfigurationResolver.isDebuggingFlask(debugConfiguration);
149-
if (debugConfiguration.autoStartBrowser && (debugConfiguration.django || isFlask)) {
149+
if (
150+
debugConfiguration.autoStartBrowser &&
151+
(debugConfiguration.django || isFlask) &&
152+
!debugConfiguration.serverReadyAction
153+
) {
150154
debugConfiguration.serverReadyAction = {
151155
pattern: '.*(https?:\\/\\/\\S+:[0-9]+\\/?).*',
152156
uriFormat: '%s',

src/test/unittest/configuration/resolvers/launch.unit.test.ts

+33
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,39 @@ getInfoPerOS().forEach(([osName, osType, path]) => {
953953
});
954954
});
955955

956+
test('Preserve serverReadyAction when already defined in configuration', async () => {
957+
const pythonPath = `PythonPath_${new Date().toString()}`;
958+
const workspaceFolder = createMoqWorkspaceFolder(__dirname);
959+
const pythonFile = 'xyz.py';
960+
setupIoc(pythonPath);
961+
setupActiveEditor(pythonFile, PYTHON_LANGUAGE);
962+
963+
const customServerReadyAction = {
964+
pattern: '.*Running on (http://\\S+:[0-9]+).*',
965+
uriFormat: '%s/custom',
966+
action: 'debugWithChrome',
967+
};
968+
969+
testsForautoStartBrowser.forEach(async (testParams) => {
970+
const debugConfig = await resolveDebugConfiguration(workspaceFolder, {
971+
...launch,
972+
...testParams,
973+
serverReadyAction: customServerReadyAction,
974+
});
975+
976+
expect(debugConfig).to.have.property('serverReadyAction', customServerReadyAction);
977+
if (!debugConfig) {
978+
throw new Error('Debug config is undefined');
979+
}
980+
expect(debugConfig.serverReadyAction).to.deep.equal(customServerReadyAction);
981+
expect(debugConfig.serverReadyAction).to.not.deep.equal({
982+
pattern: '.*(https?:\\/\\/\\S+:[0-9]+\\/?).*',
983+
uriFormat: '%s',
984+
action: 'openExternally',
985+
});
986+
});
987+
});
988+
956989
test('Send consoleName value to debugpy as consoleTitle', async () => {
957990
const consoleName = 'My Console Name';
958991
const pythonPath = `PythonPath_${new Date().toString()}`;

0 commit comments

Comments
 (0)