Skip to content

Commit c932e8a

Browse files
authored
Fix run by line to scroll to the current location when stepping (microsoft#11754)
* Fix run by line to scroll to the current location when stepping Fix install message to reference run by line * Add in icon changes as well * Fix merge error too
1 parent 1d15bbf commit c932e8a

File tree

11 files changed

+62
-20
lines changed

11 files changed

+62
-20
lines changed

news/2 Fixes/11661.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix install message to reference run by line instead of debugging.

news/2 Fixes/11662.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Run by line does not scroll to the line that is being run.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1764,7 +1764,7 @@
17641764
"python.dataScience.alwaysScrollOnNewCell": {
17651765
"type": "boolean",
17661766
"default": false,
1767-
"description": "If a new cell comes in, scroll the interactive window to the bottom regardless of where the scroll bar is. The default is to only scroll if the current position was already at the bottom when the new cell is created",
1767+
"description": "Automatically scroll the interactive window to show the output of the last statement executed. If false, the interactive window will only automatically scroll if the bottom of the prior cell is visible.",
17681768
"scope": "resource"
17691769
},
17701770
"python.dataScience.enableScrollingForCellOutputs": {

package.nls.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,9 @@
403403
"DataScience.jupyterDebuggerPortNotAvailableSearchError": "Ports in the range {0}-{1} cannot be found for debugging. Please specify a port in the remoteDebuggerPort setting.",
404404
"DataScience.jupyterDebuggerPortBlockedSearchError": "A port cannot be connected to for debugging. Please let ports {0}-{1} through your firewall.",
405405
"DataScience.jupyterDebuggerInstallNew": "Pip module {0} is required for debugging cells. Install {0} and continue to debug cell?",
406+
"DataScience.jupyterDebuggerInstallNewRunByLine": "Pip module {0} is required for running by line. Install {0} and continue to run by line?",
406407
"DataScience.jupyterDebuggerInstallUpdate": "The version of {0} installed does not support debugging cells. Update {0} to newest version and continue to debug cell?",
408+
"DataScience.jupyterDebuggerInstallUpdateRunByLine": "The version of {0} installed does not support running by line. Update {0} to newest version and continue to run by line?",
407409
"DataScience.jupyterDebuggerInstallYes": "Yes",
408410
"DataScience.jupyterDebuggerInstallNo": "No",
409411
"DataScience.cellStopOnErrorFormatMessage": "{0} cells were canceled due to an error in the previous cell.",

src/client/common/utils/localize.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,10 +714,18 @@ export namespace DataScience {
714714
'DataScience.jupyterDebuggerInstallNew',
715715
'Pip module {0} is required for debugging cells. Install {0} and continue to debug cell?'
716716
);
717+
export const jupyterDebuggerInstallNewRunByLine = localize(
718+
'DataScience.jupyterDebuggerInstallNewRunByLine',
719+
'Pip module {0} is required for running by line. Install {0} and continue to run by line?'
720+
);
717721
export const jupyterDebuggerInstallUpdate = localize(
718722
'DataScience.jupyterDebuggerInstallUpdate',
719723
'The version of {0} installed does not support debugging cells. Update {0} to newest version and continue to debug cell?'
720724
);
725+
export const jupyterDebuggerInstallUpdateRunByLine = localize(
726+
'DataScience.jupyterDebuggerInstallUpdateRunByLine',
727+
'The version of {0} installed does not support running by line. Update {0} to newest version and continue to run by line?'
728+
);
721729
export const jupyterDebuggerInstallYes = localize('DataScience.jupyterDebuggerInstallYes', 'Yes');
722730
export const jupyterDebuggerInstallNo = localize('DataScience.jupyterDebuggerInstallNo', 'No');
723731
export const cellStopOnErrorFormatMessage = localize(

src/client/datascience/jupyter/jupyterDebugger.ts

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,19 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
8282
}
8383
]
8484
};
85-
return this.startDebugSession((c) => this.debugService.startRunByLine(c), notebook, config);
85+
return this.startDebugSession((c) => this.debugService.startRunByLine(c), notebook, config, true);
8686
}
8787

8888
public async startDebugging(notebook: INotebook): Promise<void> {
8989
const settings = this.configService.getSettings(notebook.resource);
90-
return this.startDebugSession((c) => this.debugService.startDebugging(undefined, c), notebook, {
91-
justMyCode: settings.datascience.debugJustMyCode
92-
});
90+
return this.startDebugSession(
91+
(c) => this.debugService.startDebugging(undefined, c),
92+
notebook,
93+
{
94+
justMyCode: settings.datascience.debugJustMyCode
95+
},
96+
false
97+
);
9398
}
9499

95100
public async stopDebugging(notebook: INotebook): Promise<void> {
@@ -129,12 +134,13 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
129134
private async startDebugSession(
130135
startCommand: (config: DebugConfiguration) => Thenable<boolean>,
131136
notebook: INotebook,
132-
extraConfig: Partial<DebugConfiguration>
137+
extraConfig: Partial<DebugConfiguration>,
138+
runByLine: boolean
133139
) {
134140
traceInfo('start debugging');
135141

136142
// Try to connect to this notebook
137-
const config = await this.connect(notebook, extraConfig);
143+
const config = await this.connect(notebook, runByLine, extraConfig);
138144
if (config) {
139145
traceInfo('connected to notebook during debugging');
140146

@@ -182,6 +188,7 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
182188

183189
private async connect(
184190
notebook: INotebook,
191+
runByLine: boolean,
185192
extraConfig: Partial<DebugConfiguration>
186193
): Promise<DebugConfiguration | undefined> {
187194
// If we already have configuration, we're already attached, don't do it again.
@@ -203,7 +210,7 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
203210

204211
// If we don't have debugger installed or the version is too old then we need to install it
205212
if (!debuggerVersion || !this.debuggerMeetsRequirement(debuggerVersion, requiredVersion)) {
206-
await this.promptToInstallDebugger(notebook, debuggerVersion);
213+
await this.promptToInstallDebugger(notebook, debuggerVersion, runByLine);
207214
}
208215

209216
// Connect local or remote based on what type of notebook we're talking to
@@ -387,10 +394,18 @@ export class JupyterDebugger implements IJupyterDebugger, ICellHashListener {
387394
}
388395

389396
@captureTelemetry(Telemetry.PtvsdPromptToInstall)
390-
private async promptToInstallDebugger(notebook: INotebook, oldVersion: Version | undefined): Promise<void> {
391-
const promptMessage = oldVersion
392-
? localize.DataScience.jupyterDebuggerInstallUpdate().format(this.debuggerPackage)
397+
private async promptToInstallDebugger(
398+
notebook: INotebook,
399+
oldVersion: Version | undefined,
400+
runByLine: boolean
401+
): Promise<void> {
402+
const updateMessage = runByLine
403+
? localize.DataScience.jupyterDebuggerInstallUpdateRunByLine().format(this.debuggerPackage)
404+
: localize.DataScience.jupyterDebuggerInstallUpdate().format(this.debuggerPackage);
405+
const newMessage = runByLine
406+
? localize.DataScience.jupyterDebuggerInstallNewRunByLine().format(this.debuggerPackage)
393407
: localize.DataScience.jupyterDebuggerInstallNew().format(this.debuggerPackage);
408+
const promptMessage = oldVersion ? updateMessage : newMessage;
394409
const result = await this.appShell.showInformationMessage(
395410
promptMessage,
396411
localize.DataScience.jupyterDebuggerInstallYes(),

src/datascience-ui/interactive-common/editor.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export class Editor extends React.Component<IEditorProps> {
5757
private lastCleanVersionId: number = 0;
5858
private monacoRef: React.RefObject<MonacoEditor> = React.createRef<MonacoEditor>();
5959
private modelRef: monacoEditor.editor.ITextModel | null = null;
60+
private editorRef: monacoEditor.editor.IStandaloneCodeEditor | null = null;
6061
private decorationIds: string[] = [];
6162

6263
constructor(prop: IEditorProps) {
@@ -76,6 +77,9 @@ export class Editor extends React.Component<IEditorProps> {
7677
} else if (this.decorationIds.length) {
7778
this.decorationIds = this.modelRef.deltaDecorations(this.decorationIds, []);
7879
}
80+
if (this.editorRef && this.props.ipLocation) {
81+
this.editorRef.setPosition({ lineNumber: this.props.ipLocation, column: 1 });
82+
}
7983
}
8084
}
8185
}
@@ -176,6 +180,7 @@ export class Editor extends React.Component<IEditorProps> {
176180
};
177181

178182
private editorDidMount = (editor: monacoEditor.editor.IStandaloneCodeEditor) => {
183+
this.editorRef = editor;
179184
const model = editor.getModel();
180185
this.modelRef = model;
181186

src/datascience-ui/native-editor/nativeCell.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,12 +572,14 @@ export class NativeCell extends React.Component<INativeCellProps> {
572572
this.props.sendCommand(NativeMouseCommandTelemetry.DeleteCell);
573573
};
574574
const runbyline = () => {
575+
this.props.focusCell(cellId);
575576
this.props.runByLine(cellId);
576577
};
577578
const cont = () => {
578579
this.props.continue(cellId);
579580
};
580581
const step = () => {
582+
this.props.focusCell(cellId);
581583
this.props.step(cellId);
582584
};
583585
const gatherDisabled =
Lines changed: 8 additions & 4 deletions
Loading
Lines changed: 8 additions & 4 deletions
Loading

0 commit comments

Comments
 (0)