Skip to content

Commit 7b628d0

Browse files
authored
Ensure users can override defaults in experimental debugger (microsoft#1540)
* Ensure users can override defaults in experimental debugger * Fixes microsoft#1539
1 parent 9f1d10a commit 7b628d0

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

src/client/debugger/configProviders/baseProvider.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { IDocumentManager, IWorkspaceService } from '../../common/application/ty
1212
import { PYTHON_LANGUAGE } from '../../common/constants';
1313
import { IConfigurationService } from '../../common/types';
1414
import { IServiceContainer } from '../../ioc/types';
15-
import { BaseAttachRequestArguments, BaseLaunchRequestArguments, DebuggerType, DebugOptions } from '../Common/Contracts';
15+
import { BaseAttachRequestArguments, BaseLaunchRequestArguments, DebuggerType } from '../Common/Contracts';
1616

1717
export type PythonLaunchDebugConfiguration<T extends BaseLaunchRequestArguments> = DebugConfiguration & T;
1818
export type PythonAttachDebugConfiguration<T extends BaseAttachRequestArguments> = DebugConfiguration & T;
@@ -78,10 +78,6 @@ export abstract class BaseConfigurationProvider<L extends BaseLaunchRequestArgum
7878
if (!Array.isArray(debugConfiguration.debugOptions)) {
7979
debugConfiguration.debugOptions = [];
8080
}
81-
// Always redirect output.
82-
if (debugConfiguration.debugOptions.indexOf(DebugOptions.RedirectOutput) === -1) {
83-
debugConfiguration.debugOptions.push(DebugOptions.RedirectOutput);
84-
}
8581
}
8682
private getWorkspaceFolder(folder: WorkspaceFolder | undefined): Uri | undefined {
8783
if (folder) {

src/client/debugger/configProviders/pythonProvider.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ export class PythonDebugConfigurationProvider extends BaseConfigurationProvider<
1717
}
1818
protected async provideLaunchDefaults(workspaceFolder: Uri, debugConfiguration: PythonLaunchDebugConfiguration<LaunchRequestArgumentsV1>): Promise<void> {
1919
await super.provideLaunchDefaults(workspaceFolder, debugConfiguration);
20+
// Always redirect output.
21+
if (debugConfiguration.debugOptions!.indexOf(DebugOptions.RedirectOutput) === -1) {
22+
debugConfiguration.debugOptions!.push(DebugOptions.RedirectOutput);
23+
}
2024
if (debugConfiguration.debugOptions!.indexOf(DebugOptions.Pyramid) >= 0) {
2125
const utils = this.serviceContainer.get<IConfigurationProviderUtils>(IConfigurationProviderUtils);
2226
debugConfiguration.program = (await utils.getPyramidStartupScriptFilePath(workspaceFolder))!;

src/test/debugger/configProvider/provider.test.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import { IFileSystem, IPlatformService } from '../../../client/common/platform/t
1515
import { IPythonExecutionFactory, IPythonExecutionService } from '../../../client/common/process/types';
1616
import { IConfigurationService, IPythonSettings } from '../../../client/common/types';
1717
import { PythonDebugConfigurationProvider, PythonV2DebugConfigurationProvider } from '../../../client/debugger';
18-
import { DebugOptions } from '../../../client/debugger/Common/Contracts';
18+
import { DebugOptions, LaunchRequestArguments } from '../../../client/debugger/Common/Contracts';
19+
import { PythonLaunchDebugConfiguration } from '../../../client/debugger/configProviders/baseProvider';
1920
import { ConfigurationProviderUtils } from '../../../client/debugger/configProviders/configurationProviderUtils';
2021
import { IConfigurationProviderUtils } from '../../../client/debugger/configProviders/types';
2122
import { IServiceContainer } from '../../../client/ioc/types';
@@ -279,6 +280,23 @@ import { IServiceContainer } from '../../../client/ioc/types';
279280
expect(debugConfig).to.have.property('debugOptions');
280281
expect((debugConfig as any).debugOptions).to.be.deep.equal([DebugOptions.RedirectOutput]);
281282
});
283+
test('Test overriding defaults of experimental debugger', async () => {
284+
if (provider.debugType !== 'pythonExperimental') {
285+
return;
286+
}
287+
const pythonPath = `PythonPath_${new Date().toString()}`;
288+
const workspaceFolder = createMoqWorkspaceFolder(__dirname);
289+
const pythonFile = 'xyz.py';
290+
setupIoc(pythonPath);
291+
setupActiveEditor(pythonFile, PYTHON_LANGUAGE);
292+
293+
const debugConfig = await debugProvider.resolveDebugConfiguration!(workspaceFolder, { redirectOutput: false } as PythonLaunchDebugConfiguration<LaunchRequestArguments>);
294+
295+
expect(debugConfig).to.have.property('console', 'integratedTerminal');
296+
expect(debugConfig).to.have.property('stopOnEntry', false);
297+
expect(debugConfig).to.have.property('debugOptions');
298+
expect((debugConfig as any).debugOptions).to.be.deep.equal([]);
299+
});
282300
async function testFixFilePathCase(isWindows: boolean, isMac: boolean, isLinux: boolean) {
283301
const pythonPath = `PythonPath_${new Date().toString()}`;
284302
const workspaceFolder = createMoqWorkspaceFolder(__dirname);

0 commit comments

Comments
 (0)