Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Handle debugger lifecycle #290

Merged
merged 16 commits into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/breakpoints/body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ const BreakpointCellComponent = ({
.sort((a, b) => {
return a.line - b.line;
})
.map((breakpoint: IDebugger.IBreakpoint) => (
.map((breakpoint: IDebugger.IBreakpoint, index) => (
<BreakpointComponent
key={breakpoint.source.path + breakpoint.line}
key={breakpoint.source.path + index}
breakpoint={breakpoint}
model={model}
/>
Expand Down
3 changes: 3 additions & 0 deletions src/debugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ export namespace Debugger {
readonly sources: Sources.Model;

dispose(): void {
if (this._isDisposed) {
return;
}
this._isDisposed = true;
this._disposed.emit();
}
Expand Down
12 changes: 7 additions & 5 deletions src/handlers/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class EditorHandler implements IDisposable {
this.sendEditorBreakpoints();
}, this);

this.setup();
this.setupEditor();
}

isDisposed: boolean;
Expand Down Expand Up @@ -79,9 +79,9 @@ export class EditorHandler implements IDisposable {
return;
}
this._editorMonitor.dispose();
this.removeGutterClick();
Signal.clearData(this);
this.clearEditor();
this.isDisposed = true;
Signal.clearData(this);
}

protected sendEditorBreakpoints() {
Expand All @@ -104,7 +104,7 @@ export class EditorHandler implements IDisposable {
);
}

protected setup() {
protected setupEditor() {
if (!this._editor || this._editor.isDisposed) {
return;
}
Expand All @@ -120,11 +120,13 @@ export class EditorHandler implements IDisposable {
editor.editor.on('gutterClick', this.onGutterClick);
}

protected removeGutterClick() {
protected clearEditor() {
if (!this._editor || this._editor.isDisposed) {
return;
}
const editor = this._editor as CodeMirrorEditor;
editor.setOption('lineNumbers', false);
editor.editor.setOption('gutters', []);
editor.editor.off('gutterClick', this.onGutterClick);
}

Expand Down
6 changes: 4 additions & 2 deletions src/handlers/file.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import { DocumentWidget } from '@jupyterlab/docregistry';

import { FileEditor } from '@jupyterlab/fileeditor';

import { IDisposable } from '@phosphor/disposable';
Expand All @@ -14,7 +16,7 @@ import { IDebugger } from '../tokens';
export class FileHandler implements IDisposable {
constructor(options: DebuggerFileHandler.IOptions) {
this.debuggerService = options.debuggerService;
this.fileEditor = options.widget;
this.fileEditor = options.widget.content;

this.editorHandler = new EditorHandler({
debuggerService: this.debuggerService,
Expand All @@ -41,6 +43,6 @@ export class FileHandler implements IDisposable {
export namespace DebuggerFileHandler {
export interface IOptions {
debuggerService: IDebugger;
widget: FileEditor;
widget: DocumentWidget<FileEditor>;
}
}
Loading