Browse Source

higthline next on next frame

Borys Palka 5 years ago
parent
commit
be838890ca
4 changed files with 24 additions and 15 deletions
  1. 6 0
      src/debugger.ts
  2. 4 0
      src/handlers/cell.ts
  3. 5 4
      src/index.ts
  4. 9 11
      src/service.ts

+ 6 - 0
src/debugger.ts

@@ -36,6 +36,7 @@ export class Debugger extends SplitPanel {
     this.model = new Debugger.Model(options);
     this.model = new Debugger.Model(options);
 
 
     this.sidebar = new DebuggerSidebar();
     this.sidebar = new DebuggerSidebar();
+
     this.model.sidebar = this.sidebar;
     this.model.sidebar = this.sidebar;
 
 
     this.service = new DebugService(this.model);
     this.service = new DebugService(this.model);
@@ -127,6 +128,10 @@ export namespace Debugger {
       return this._currentLineChanged;
       return this._currentLineChanged;
     }
     }
 
 
+    get clearLines() {
+      return this._clearLines;
+    }
+
     dispose(): void {
     dispose(): void {
       this._isDisposed = true;
       this._isDisposed = true;
     }
     }
@@ -145,6 +150,7 @@ export namespace Debugger {
     private _mode: IDebugger.Mode;
     private _mode: IDebugger.Mode;
     private _modeChanged = new Signal<this, IDebugger.Mode>(this);
     private _modeChanged = new Signal<this, IDebugger.Mode>(this);
     private _currentLineChanged = new Signal<this, number>(this);
     private _currentLineChanged = new Signal<this, number>(this);
+    private _clearLines = new Signal<this, void>(this);
   }
   }
 
 
   export namespace Model {
   export namespace Model {

+ 4 - 0
src/handlers/cell.ts

@@ -36,6 +36,10 @@ export class CellManager implements IDisposable {
     this._debuggerModel.currentLineChanged.connect((_, lineNumber) => {
     this._debuggerModel.currentLineChanged.connect((_, lineNumber) => {
       this.showCurrentLine(lineNumber);
       this.showCurrentLine(lineNumber);
     });
     });
+
+    this._debuggerModel.clearLines.connect(() => {
+      this.cleanupHighlight();
+    });
   }
   }
 
 
   private _previousCell: CodeCell;
   private _previousCell: CodeCell;

+ 5 - 4
src/index.ts

@@ -33,6 +33,7 @@ import { DebuggerNotebookHandler } from './handlers/notebook';
 import { DebuggerConsoleHandler } from './handlers/console';
 import { DebuggerConsoleHandler } from './handlers/console';
 
 
 import { Kernel } from '@jupyterlab/services';
 import { Kernel } from '@jupyterlab/services';
+
 import { IEditorServices } from '@jupyterlab/codeeditor';
 import { IEditorServices } from '@jupyterlab/codeeditor';
 
 
 /**
 /**
@@ -217,7 +218,7 @@ const notebooks: JupyterFrontEndPlugin<void> = {
  */
  */
 const main: JupyterFrontEndPlugin<IDebugger> = {
 const main: JupyterFrontEndPlugin<IDebugger> = {
   id: '@jupyterlab/debugger:main',
   id: '@jupyterlab/debugger:main',
-  optional: [ILayoutRestorer, ICommandPalette],
+  optional: [ILayoutRestorer, ICommandPalette, ILabShell],
   requires: [IStateDB, IEditorServices],
   requires: [IStateDB, IEditorServices],
   provides: IDebugger,
   provides: IDebugger,
   autoStart: true,
   autoStart: true,
@@ -226,7 +227,8 @@ const main: JupyterFrontEndPlugin<IDebugger> = {
     state: IStateDB,
     state: IStateDB,
     editorServices: IEditorServices,
     editorServices: IEditorServices,
     restorer: ILayoutRestorer | null,
     restorer: ILayoutRestorer | null,
-    palette: ICommandPalette | null
+    palette: ICommandPalette | null,
+    labShell: ILabShell
   ): IDebugger => {
   ): IDebugger => {
     const tracker = new WidgetTracker<MainAreaWidget<Debugger>>({
     const tracker = new WidgetTracker<MainAreaWidget<Debugger>>({
       namespace: 'debugger'
       namespace: 'debugger'
@@ -268,7 +270,6 @@ const main: JupyterFrontEndPlugin<IDebugger> = {
             sidebar.parent = null;
             sidebar.parent = null;
           }
           }
 
 
-          // edge case when reload page after set condensed mode
           widget.title.label = 'Debugger';
           widget.title.label = 'Debugger';
           shell.add(widget, 'main');
           shell.add(widget, 'main');
           return;
           return;
@@ -281,7 +282,7 @@ const main: JupyterFrontEndPlugin<IDebugger> = {
 
 
         sidebar.id = 'jp-debugger-sidebar';
         sidebar.id = 'jp-debugger-sidebar';
         sidebar.title.label = 'Environment';
         sidebar.title.label = 'Environment';
-        shell.add(sidebar, 'right', { activate: false });
+        shell.add(sidebar, 'right', { activate: true });
       }
       }
     });
     });
 
 

+ 9 - 11
src/service.ts

@@ -31,10 +31,13 @@ export class DebugService implements IDebugger.IService {
     this._session = session;
     this._session = session;
 
 
     this._session.eventMessage.connect((_, event) => {
     this._session.eventMessage.connect((_, event) => {
+      console.log({ event });
       if (event.event === 'stopped') {
       if (event.event === 'stopped') {
         this._threadStopped.add(event.body.threadId);
         this._threadStopped.add(event.body.threadId);
+        void this.getFramesAllData();
       } else if (event.event === 'continued') {
       } else if (event.event === 'continued') {
         this._threadStopped.delete(event.body.threadId);
         this._threadStopped.delete(event.body.threadId);
+        this._model.clearLines.emit();
       }
       }
       this._eventMessage.emit(event);
       this._eventMessage.emit(event);
     });
     });
@@ -98,16 +101,7 @@ export class DebugService implements IDebugger.IService {
 
 
   // this will change for after execute cell
   // this will change for after execute cell
   async launch(code: string): Promise<void> {
   async launch(code: string): Promise<void> {
-    let threadId: number = 1;
     this.frames = [];
     this.frames = [];
-    this.session.eventMessage.connect((_, event: IDebugger.ISession.Event) => {
-      const eventName = event.event;
-      if (eventName === 'thread') {
-        const msg = event as DebugProtocol.ThreadEvent;
-        threadId = msg.body.threadId;
-      }
-    });
-
     const breakpoints: DebugProtocol.SourceBreakpoint[] = this.setBreakpoints();
     const breakpoints: DebugProtocol.SourceBreakpoint[] = this.setBreakpoints();
     const reply = await this.session.sendRequest('dumpCell', {
     const reply = await this.session.sendRequest('dumpCell', {
       code
       code
@@ -122,7 +116,11 @@ export class DebugService implements IDebugger.IService {
 
 
     this.session.client.kernel.requestExecute({ code });
     this.session.client.kernel.requestExecute({ code });
 
 
-    const stackFrames = await this.getFrames(threadId);
+    await this.getFramesAllData();
+  }
+
+  getFramesAllData = async () => {
+    const stackFrames = await this.getFrames(this.currentThread());
 
 
     stackFrames.forEach(async (frame, index) => {
     stackFrames.forEach(async (frame, index) => {
       const scopes = await this.getScopes(frame);
       const scopes = await this.getScopes(frame);
@@ -145,7 +143,7 @@ export class DebugService implements IDebugger.IService {
     this._model.sidebar.callstack.model.currentFrameChanged.connect(
     this._model.sidebar.callstack.model.currentFrameChanged.connect(
       this.onChangeFrame
       this.onChangeFrame
     );
     );
-  }
+  };
 
 
   onChangeFrame = (_: Callstack.IModel, update: Callstack.IFrame) => {
   onChangeFrame = (_: Callstack.IModel, update: Callstack.IFrame) => {
     const frame = this.frames.find(ele => ele.id === update.id);
     const frame = this.frames.find(ele => ele.id === update.id);