Skip to content

Commit 5f6ba83

Browse files
authored
Fix a number of debugging issues (#6757)
* Fix a number of debugging issues * Add another news entry * Fix code watcher tests after adding back Run Below
1 parent 76f5fd8 commit 5f6ba83

25 files changed

Lines changed: 192 additions & 146 deletions

news/2 Fixes/6730.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
In order to debug without '#%%' defined in a file, support a Debug Entire File.

news/2 Fixes/6737.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add support for Run Below back.

news/2 Fixes/6740.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix the 'Variables not available while debugging' message to be more descriptive.

news/2 Fixes/6743.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Make breakpoints on enter always be the case unless 'stopOnFirstLineWhileDebugging' is set.

news/2 Fixes/6754.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove Debug Cell and Run Cell from the command palette. They should both be 'Debug Current Cell' and 'Run Current Cell'

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,6 @@
351351
"title": "%python.command.python.datascience.runcurrentcell.title%",
352352
"category": "Python"
353353
},
354-
{
355-
"command": "python.datascience.debugcell",
356-
"title": "%python.command.python.datascience.debugcell.title%",
357-
"category": "Python"
358-
},
359354
{
360355
"command": "python.datascience.runcurrentcelladvance",
361356
"title": "%python.command.python.datascience.runcurrentcelladvance.title%",
@@ -391,6 +386,11 @@
391386
"title": "%python.command.python.datascience.runFileInteractive.title%",
392387
"category": "Python"
393388
},
389+
{
390+
"command": "python.datascience.debugFileInteractive",
391+
"title": "%python.command.python.datascience.debugFileInteractive.title%",
392+
"category": "Python"
393+
},
394394
{
395395
"command": "python.datascience.runallcells",
396396
"title": "%python.command.python.datascience.runallcells.title%",
@@ -720,14 +720,14 @@
720720
"when": "python.datascience.featureenabled"
721721
},
722722
{
723-
"command": "python.datascience.runcell",
724-
"title": "%python.command.python.datascience.runcell.title%",
723+
"command": "python.datascience.runFileInteractive",
724+
"title": "%python.command.python.datascience.runFileInteractive.title%",
725725
"category": "Python",
726726
"when": "python.datascience.featureenabled"
727727
},
728728
{
729-
"command": "python.datascience.runFileInteractive",
730-
"title": "%python.command.python.datascience.runFileInteractive.title%",
729+
"command": "python.datascience.debugFileInteractive",
730+
"title": "%python.command.python.datascience.debugFileInteractive.title%",
731731
"category": "Python",
732732
"when": "python.datascience.featureenabled"
733733
},
@@ -1439,7 +1439,7 @@
14391439
"python.dataScience.stopOnFirstLineWhileDebugging": {
14401440
"type": "boolean",
14411441
"default": true,
1442-
"description": "When debugging a cell, stop on the first line if no other breakpoints in the current cell.",
1442+
"description": "When debugging a cell, stop on the first line.",
14431443
"scope": "resource"
14441444
},
14451445
"python.dataScience.remoteDebuggerPort": {

package.nls.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"python.command.python.enableLinting.title": "Enable Linting",
3232
"python.command.python.runLinting.title": "Run Linting",
3333
"python.command.python.datascience.runFileInteractive.title": "Run Current File in Python Interactive Window",
34+
"python.command.python.datascience.debugFileInteractive.title": "Debug Current File in Python Interactive Window",
3435
"python.command.python.datascience.runallcells.title": "Run All Cells",
3536
"python.command.python.datascience.runallcellsabove.title": "Run Above",
3637
"python.command.python.datascience.runcellandallbelow.title": "Run Below",
@@ -305,7 +306,7 @@
305306
"DataScience.addCellBelowCommandTitle": "Add cell",
306307
"DataScience.debugCellCommandTitle": "Debug cell",
307308
"DataScience.runCurrentCellAndAddBelow": "Run current and add cell below",
308-
"DataScience.variableExplorerDisabledDuringDebugging": "Variables are not available while debugging.",
309+
"DataScience.variableExplorerDisabledDuringDebugging": "Please see the Debug Side Bar's VARIABLES section.",
309310
"DataScience.jupyterDebuggerNotInstalledError": "Pip module ptvsd is required for debugging cells. You will need to install it to debug cells.",
310311
"DataScience.jupyterDebuggerPortNotAvailableError": "Port {0} cannot be opened for debugging. Please specify a different port in the remoteDebuggerPort setting.",
311312
"DataScience.jupyterDebuggerPortBlockedError": "Port {0} cannot be connected to for debugging. Please let port {0} through your firewall.",
@@ -317,5 +318,6 @@
317318
"DataScience.jupyterDebuggerInstallPtvsdNo": "No",
318319
"DataScience.cellStopOnErrorFormatMessage": "{0} cells were canceled due to an error in the previous cell.",
319320
"DataScience.instructionComments": "# To add a new cell, type '#%%'\n# To add a new markdown cell, type '#%% [markdown]'\n",
320-
"DataScience.scrollToCellTitleFormatMessage": "Go to [{0}]"
321+
"DataScience.scrollToCellTitleFormatMessage": "Go to [{0}]",
322+
"DataScience.remoteDebuggerNotSupported" : "Debugging while attached to a remote server is not currently supported."
321323
}

src/client/common/application/commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ export interface ICommandNameArgumentTypeMapping extends ICommandNameWithoutArgu
113113
[DSCommands.ImportNotebook]: [undefined | Uri, undefined | CommandSource];
114114
[DSCommands.ExportFileAsNotebook]: [undefined | Uri, undefined | CommandSource];
115115
[DSCommands.RunFileInInteractiveWindows]: [string];
116+
[DSCommands.DebugFileInInteractiveWindows]: [string];
116117
[DSCommands.DebugCell]: [string, number, number, number, number];
117118
[DSCommands.RunCurrentCellAndAddBelow]: [string];
118119
[DSCommands.ScrollToCell]: [string, string];

src/client/common/utils/localize.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ export namespace DataScience {
230230
export const addCellBelowCommandTitle = localize('DataScience.addCellBelowCommandTitle', 'Add cell');
231231
export const debugCellCommandTitle = localize('DataScience.debugCellCommandTitle', 'Debug cell');
232232
export const runCurrentCellAndAddBelow = localize('DataScience.runCurrentCellAndAddBelow', 'Run current and add cell below');
233-
export const variableExplorerDisabledDuringDebugging = localize('DataScience.variableExplorerDisabledDuringDebugging', 'Variables are not available while debugging.');
233+
export const variableExplorerDisabledDuringDebugging = localize('DataScience.variableExplorerDisabledDuringDebugging', 'Please see the Debug Side Bar\'s VARIABLES section.');
234234
export const jupyterDebuggerNotInstalledError = localize('DataScience.jupyterDebuggerNotInstalledError', 'Pip module ptvsd is required for debugging cells. You will need to install it to debug cells.');
235235
export const jupyterDebuggerPortNotAvailableError = localize('DataScience.jupyterDebuggerPortNotAvailableError', 'Port {0} cannot be opened for debugging. Please specify a different port in the remoteDebuggerPort setting.');
236236
export const jupyterDebuggerPortBlockedError = localize('DataScience.jupyterDebuggerPortBlockedError', 'Port {0} cannot be connected to for debugging. Please let port {0} through your firewall.');
@@ -243,6 +243,7 @@ export namespace DataScience {
243243
export const cellStopOnErrorFormatMessage = localize('DataScience.cellStopOnErrorFormatMessage', '{0} cells were canceled due to an error in the previous cell.');
244244
export const scrollToCellTitleFormatMessage = localize('DataScience.scrollToCellTitleFormatMessage', 'Go to [{0}]');
245245
export const instructionComments = localize('DataScience.instructionComments', '# To add a new cell, type "#%%"\n# To add a new markdown cell, type "#%% [markdown]"\n');
246+
export const remoteDebuggerNotSupported = localize('DataScience.remoteDebuggerNotSupported', 'Debugging while attached to a remote server is not currently supported.');
246247
}
247248

248249
export namespace DebugConfigStrings {

src/client/datascience/cellMatcher.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import { noop } from '../common/utils/misc';
88
import { RegExpValues } from './constants';
99

1010
export class CellMatcher {
11-
private codeMatchRegEx : RegExp;
12-
private markdownMatchRegEx : RegExp;
11+
private codeMatchRegEx: RegExp;
12+
private markdownMatchRegEx: RegExp;
1313
private codeExecRegEx: RegExp;
14-
private markdownExecRegEx : RegExp;
14+
private markdownExecRegEx: RegExp;
1515

1616
constructor(settings?: IDataScienceSettings) {
1717
this.codeMatchRegEx = this.createRegExp(settings ? settings.codeRegularExpression : undefined, RegExpValues.PythonCellMarker);
@@ -20,28 +20,33 @@ export class CellMatcher {
2020
this.markdownExecRegEx = new RegExp(`${this.markdownMatchRegEx.source}(.*)`);
2121
}
2222

23-
public isCell(code: string) : boolean {
23+
public isCell(code: string): boolean {
2424
return this.codeMatchRegEx.test(code) || this.markdownMatchRegEx.test(code);
2525
}
2626

27-
public isMarkdown(code: string) : boolean {
27+
public isMarkdown(code: string): boolean {
2828
return this.markdownMatchRegEx.test(code);
2929
}
3030

31-
public isCode(code: string) : boolean {
31+
public isCode(code: string): boolean {
3232
return this.codeMatchRegEx.test(code);
3333
}
3434

35-
public getCellType(code: string) : string {
35+
public getCellType(code: string): string {
3636
return this.isMarkdown(code) ? 'markdown' : 'code';
3737
}
3838

39-
public stripMarkers(code: string) : string {
40-
const lines = code.splitLines({trim: false, removeEmptyEntries: false});
41-
return lines.filter(l => !this.isCode(l) && !this.isMarkdown(l)).join('\n');
39+
public stripFirstMarker(code: string): string {
40+
const lines = code.splitLines({ trim: false, removeEmptyEntries: false });
41+
42+
// Only strip this off the first line. Otherwise we want the markers in the code.
43+
if (lines.length > 0 && (this.isCode(lines[0]) || this.isMarkdown(lines[0]))) {
44+
return lines.slice(1).join('\n');
45+
}
46+
return code;
4247
}
4348

44-
public exec(code: string) : string | undefined {
49+
public exec(code: string): string | undefined {
4550
let result: RegExpExecArray | null = null;
4651
if (this.codeMatchRegEx.test(code)) {
4752
this.codeExecRegEx.lastIndex = -1;
@@ -56,7 +61,7 @@ export class CellMatcher {
5661
return undefined;
5762
}
5863

59-
private createRegExp(potential: string | undefined, backup: RegExp) : RegExp {
64+
private createRegExp(potential: string | undefined, backup: RegExp): RegExp {
6065
try {
6166
if (potential) {
6267
return new RegExp(potential);

0 commit comments

Comments
 (0)