Skip to content

Commit 0827379

Browse files
Do not create config when esc is hit (#228)
* dont continue if esc is hit * fix lint * fix tests
1 parent 646fc7c commit 0827379

12 files changed

+18
-44
lines changed

src/extension/debugger/configuration/providers/djangoLaunch.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ export async function buildDjangoLaunchDebugConfiguration(
4242
if (selectedProgram) {
4343
manuallyEnteredAValue = true;
4444
config.program = selectedProgram;
45+
} else {
46+
return;
4547
}
4648
}
4749

src/extension/debugger/configuration/providers/fastapiLaunch.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export async function buildFastAPILaunchDebugConfiguration(
4444
if (selectedPath) {
4545
manuallyEnteredAValue = true;
4646
config.args = [`${path.basename(selectedPath, '.py').replace('/', '.')}:app`, '--reload'];
47+
} else {
48+
return;
4749
}
4850
}
4951

src/extension/debugger/configuration/providers/flaskLaunch.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ export async function buildFlaskLaunchDebugConfiguration(
4949
if (selectedApp) {
5050
manuallyEnteredAValue = true;
5151
config.env!.FLASK_APP = selectedApp;
52+
} else {
53+
return;
5254
}
5355
}
5456

src/extension/debugger/configuration/providers/moduleLaunch.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export async function buildModuleLaunchConfiguration(
3434
if (selectedModule) {
3535
manuallyEnteredAValue = true;
3636
config.module = selectedModule;
37+
} else {
38+
return;
3739
}
3840

3941
sendTelemetryEvent(EventName.DEBUGGER_CONFIGURATION_PROMPTS, undefined, {

src/extension/debugger/configuration/providers/pyramidLaunch.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ export async function buildPyramidLaunchConfiguration(
4848
if (selectedIniPath) {
4949
manuallyEnteredAValue = true;
5050
config.args = [selectedIniPath];
51+
} else {
52+
return;
5153
}
5254
}
5355

src/extension/debugger/configuration/providers/remoteAttach.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ export async function buildRemoteAttachConfiguration(
4747
value && value.trim().length > 0 ? undefined : DebugConfigStrings.attach.enterRemoteHost.invalid,
4848
),
4949
});
50+
5051
if (!connect.host) {
51-
connect.host = defaultHost;
52+
return;
5253
}
5354

5455
sendTelemetryEvent(EventName.DEBUGGER_CONFIGURATION_PROMPTS, undefined, {

src/test/unittest/configuration/providers/djangoLaunch.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ suite('Debugging - Configuration Provider Django', () => {
119119
const workspaceFolderToken = '${workspaceFolder}';
120120
const defaultProgram = `${workspaceFolderToken}-manage.py`;
121121
pathSeparatorStub.value('-');
122-
when(input.showInputBox(anything())).thenResolve();
122+
when(input.showInputBox(anything())).thenResolve(defaultProgram);
123123
await djangoLaunch.buildDjangoLaunchDebugConfiguration(instance(input), state);
124124

125125
const config = {

src/test/unittest/configuration/providers/fastapiLaunch.unit.test.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,6 @@ suite('Debugging - Configuration Provider FastAPI', () => {
4242

4343
expect(file).to.be.equal('main.py');
4444
});
45-
test('Launch JSON with valid python path', async () => {
46-
const folder = { uri: Uri.parse(path.join('one', 'two')), name: '1', index: 0 };
47-
const state = { config: {}, folder };
48-
49-
await fastApiLaunch.buildFastAPILaunchDebugConfiguration(instance(input), state);
50-
51-
const config = {
52-
name: DebugConfigStrings.fastapi.snippet.name,
53-
type: DebuggerTypeName,
54-
request: 'launch',
55-
module: 'uvicorn',
56-
args: ['main:app', '--reload'],
57-
jinja: true,
58-
};
59-
60-
expect(state.config).to.be.deep.equal(config);
61-
});
6245
test('Launch JSON with selected app path', async () => {
6346
const folder = { uri: Uri.parse(path.join('one', 'two')), name: '1', index: 0 };
6447
const state = { config: {}, folder };

src/test/unittest/configuration/providers/flaskLaunch.unit.test.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,6 @@ suite('Debugging - Configuration Provider Flask', () => {
4141

4242
expect(file).to.be.equal('app.py');
4343
});
44-
test('Launch JSON with valid python path', async () => {
45-
const folder = { uri: Uri.parse(path.join('one', 'two')), name: '1', index: 0 };
46-
const state = { config: {}, folder };
47-
48-
await flaskLaunch.buildFlaskLaunchDebugConfiguration(instance(input), state);
49-
50-
const config = {
51-
name: DebugConfigStrings.flask.snippet.name,
52-
type: DebuggerTypeName,
53-
request: 'launch',
54-
module: 'flask',
55-
env: {
56-
FLASK_APP: 'app.py',
57-
FLASK_DEBUG: '1',
58-
},
59-
args: ['run', '--no-debugger', '--no-reload'],
60-
jinja: true,
61-
};
62-
63-
expect(state.config).to.be.deep.equal(config);
64-
});
6544
test('Launch JSON with selected app path', async () => {
6645
const folder = { uri: Uri.parse(path.join('one', 'two')), name: '1', index: 0 };
6746
const state = { config: {}, folder };
@@ -88,7 +67,7 @@ suite('Debugging - Configuration Provider Flask', () => {
8867
test('Launch JSON with default managepy path', async () => {
8968
const folder = { uri: Uri.parse(path.join('one', 'two')), name: '1', index: 0 };
9069
const state = { config: {}, folder };
91-
when(input.showInputBox(anything())).thenResolve();
70+
when(input.showInputBox(anything())).thenResolve('app.py');
9271

9372
await flaskLaunch.buildFlaskLaunchDebugConfiguration(instance(input), state);
9473

src/test/unittest/configuration/providers/moduleLaunch.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ suite('Debugging - Configuration Provider Module', () => {
1919
const state = { config: {}, folder };
2020
const input = mock<MultiStepInput<DebugConfigurationState>>(MultiStepInput);
2121

22-
when(input.showInputBox(anything())).thenResolve();
22+
when(input.showInputBox(anything())).thenResolve('enter-your-module-name');
2323

2424
await buildModuleLaunchConfiguration(instance(input), state);
2525

src/test/unittest/configuration/providers/pyramidLaunch.unit.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ suite('Debugging - Configuration Provider Pyramid', () => {
9999
const folder = { uri: Uri.parse(path.join('one', 'two')), name: '1', index: 0 };
100100
const state = { config: {}, folder };
101101
pathSeparatorStub.value('-');
102+
when(input.showInputBox(anything())).thenResolve('${workspaceFolder}-development.ini');
102103

103104
await pyramidLaunch.buildPyramidLaunchConfiguration(instance(input), state);
104105

@@ -141,7 +142,7 @@ suite('Debugging - Configuration Provider Pyramid', () => {
141142
const defaultIni = `${workspaceFolderToken}-development.ini`;
142143

143144
pathSeparatorStub.value('-');
144-
when(input.showInputBox(anything())).thenResolve();
145+
when(input.showInputBox(anything())).thenResolve(defaultIni);
145146

146147
await pyramidLaunch.buildPyramidLaunchConfiguration(instance(input), state);
147148

src/test/unittest/configuration/providers/remoteAttach.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ suite('Debugging - Configuration Provider Remote Attach', () => {
6262
const folder = { uri: Uri.parse(path.join('one', 'two')), name: '1', index: 0 };
6363
const state = { config: {}, folder };
6464
let portConfigured = false;
65-
when(input.showInputBox(anything())).thenResolve();
65+
when(input.showInputBox(anything())).thenResolve('localhost');
6666

6767
sinon.stub(configuration, 'configurePort').callsFake(async () => {
6868
portConfigured = true;

0 commit comments

Comments
 (0)