-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix a bunch of debugger issues #10572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fix interactive window debugging after running cells in a notebook. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fix interactive window debugging when debugging the first cell to be run. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fix interactive window debugging for extra lines in a function. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,6 +136,7 @@ export class CellHashProvider implements ICellHashProvider, IInteractiveWindowLi | |
| return lines; | ||
| } | ||
|
|
||
| // tslint:disable-next-line: cyclomatic-complexity | ||
| public async addCellHash(cell: ICell, expectedCount: number): Promise<void> { | ||
| // Find the text document that matches. We need more information than | ||
| // the add code gives us | ||
|
|
@@ -163,14 +164,25 @@ export class CellHashProvider implements ICellHashProvider, IInteractiveWindowLi | |
| const endOffset = doc.offsetAt(endLine.rangeIncludingLineBreak.end); | ||
|
|
||
| // Jupyter also removes blank lines at the end. Make sure only one | ||
| let lastLine = stripped[stripped.length - 1]; | ||
| while (lastLine !== undefined && (lastLine.length === 0 || lastLine === '\n')) { | ||
| stripped.splice(stripped.length - 1, 1); | ||
| lastLine = stripped[stripped.length - 1]; | ||
| let lastLinePos = stripped.length - 1; | ||
| let nextToLastLinePos = stripped.length - 2; | ||
| while (nextToLastLinePos > 0) { | ||
| const lastLine = stripped[lastLinePos]; | ||
| const nextToLastLine = stripped[nextToLastLinePos]; | ||
| if ( | ||
| (lastLine.length === 0 || lastLine === '\n') && | ||
| (nextToLastLine.length === 0 || nextToLastLine === '\n') | ||
| ) { | ||
| stripped.splice(lastLinePos, 1); | ||
| lastLinePos -= 1; | ||
| nextToLastLinePos -= 1; | ||
| } else { | ||
| break; | ||
| } | ||
| } | ||
| // Make sure the last line with actual content ends with a linefeed | ||
| if (!lastLine.endsWith('\n') && lastLine.length > 0) { | ||
| stripped[stripped.length - 1] = `${lastLine}\n`; | ||
| if (!stripped[lastLinePos].endsWith('\n') && stripped[lastLinePos].length > 0) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the only fix I can see, rest look like refactoring. |
||
| stripped[lastLinePos] = `${stripped[lastLinePos]}\n`; | ||
| } | ||
|
|
||
| // Compute the runtime line and adjust our cell/stripped source for debugging | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -181,20 +181,7 @@ export class InteractiveWindow extends InteractiveBase implements IInteractiveWi | |
| } | ||
|
|
||
| public async addCode(code: string, file: string, line: number): Promise<boolean> { | ||
| if (this.lastFile && !this.fileSystem.arePathsSame(file, this.lastFile)) { | ||
| sendTelemetryEvent(Telemetry.NewFileForInteractiveWindow); | ||
| } | ||
| // Save the last file we ran with. | ||
| this.lastFile = file; | ||
|
|
||
| // Make sure our web panel opens. | ||
| await this.show(); | ||
|
|
||
| // Tell the webpanel about the new directory. | ||
| this.updateCwd(path.dirname(file)); | ||
|
|
||
| // Call the internal method. | ||
| return this.submitCode(code, file, line); | ||
| return this.addOrDebugCode(code, file, line, false); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This fixes #10395 because it 'waits' for the window to show before adding the code. |
||
| } | ||
|
|
||
| public exportCells() { | ||
|
|
@@ -252,7 +239,7 @@ export class InteractiveWindow extends InteractiveBase implements IInteractiveWi | |
|
|
||
| // Call the internal method if we were able to save | ||
| if (saved) { | ||
| return this.submitCode(code, file, line, undefined, undefined, true); | ||
| return this.addOrDebugCode(code, file, line, true); | ||
| } | ||
|
|
||
| return false; | ||
|
|
@@ -365,6 +352,23 @@ export class InteractiveWindow extends InteractiveBase implements IInteractiveWi | |
| return super.ensureServerAndNotebook(); | ||
| } | ||
|
|
||
| private async addOrDebugCode(code: string, file: string, line: number, debug: boolean): Promise<boolean> { | ||
| if (this.lastFile && !this.fileSystem.arePathsSame(file, this.lastFile)) { | ||
| sendTelemetryEvent(Telemetry.NewFileForInteractiveWindow); | ||
| } | ||
| // Save the last file we ran with. | ||
| this.lastFile = file; | ||
|
|
||
| // Make sure our web panel opens. | ||
| await this.show(); | ||
|
|
||
| // Tell the webpanel about the new directory. | ||
| this.updateCwd(path.dirname(file)); | ||
|
|
||
| // Call the internal method. | ||
| return this.submitCode(code, file, line, undefined, undefined, debug); | ||
| } | ||
|
|
||
| @captureTelemetry(Telemetry.ExportNotebook, undefined, false) | ||
| // tslint:disable-next-line: no-any no-empty | ||
| private async export(cells: ICell[]) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ import { | |
| } from '../../../common/types'; | ||
| import * as localize from '../../../common/utils/localize'; | ||
| import { IInterpreterService } from '../../../interpreter/contracts'; | ||
| import { IServiceContainer } from '../../../ioc/types'; | ||
| import { Identifiers, LiveShare, LiveShareCommands, RegExpValues } from '../../constants'; | ||
| import { | ||
| IDataScience, | ||
|
|
@@ -55,14 +56,22 @@ export class HostJupyterServer extends LiveShareParticipantHost(JupyterServerBas | |
| configService: IConfigurationService, | ||
| sessionManager: IJupyterSessionManagerFactory, | ||
| private workspaceService: IWorkspaceService, | ||
| loggers: INotebookExecutionLogger[], | ||
| serviceContainer: IServiceContainer, | ||
| private appService: IApplicationShell, | ||
| private fs: IFileSystem, | ||
| private readonly kernelSelector: KernelSelector, | ||
| private readonly interpreterService: IInterpreterService, | ||
| outputChannel: IOutputChannel | ||
| ) { | ||
| super(liveShare, asyncRegistry, disposableRegistry, configService, sessionManager, loggers, outputChannel); | ||
| super( | ||
| liveShare, | ||
| asyncRegistry, | ||
| disposableRegistry, | ||
| configService, | ||
| sessionManager, | ||
| serviceContainer, | ||
| outputChannel | ||
| ); | ||
| } | ||
|
|
||
| public async dispose(): Promise<void> { | ||
|
|
@@ -163,7 +172,7 @@ export class HostJupyterServer extends LiveShareParticipantHost(JupyterServerBas | |
| possibleSession: IJupyterSession | undefined, | ||
| disposableRegistry: IDisposableRegistry, | ||
| configService: IConfigurationService, | ||
| loggers: INotebookExecutionLogger[], | ||
| serviceContainer: IServiceContainer, | ||
| notebookMetadata?: nbformat.INotebookMetadata, | ||
| cancelToken?: CancellationToken | ||
| ): Promise<INotebook> { | ||
|
|
@@ -208,7 +217,7 @@ export class HostJupyterServer extends LiveShareParticipantHost(JupyterServerBas | |
| disposableRegistry, | ||
| this, | ||
| info, | ||
| loggers, | ||
| serviceContainer.getAll<INotebookExecutionLogger>(INotebookExecutionLogger), | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This fixes #10206 because it generates new loggers for each notebook instead of having a single set for all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This helps a lot, eg. tomorrow one can look at a PR and understand the need for the change.. (e.g. it wasn't obvious to me). Thanks |
||
| resource, | ||
| identity, | ||
| this.getDisposedError.bind(this), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes #10396