Explorar o código

Add the stop button to the callstack toolbar

Jeremy Tuloup %!s(int64=5) %!d(string=hai) anos
pai
achega
03ccb25c98
Modificáronse 3 ficheiros con 31 adicións e 0 borrados
  1. 13 0
      src/callstack/index.ts
  2. 17 0
      src/index.ts
  3. 1 0
      tests/src/debugger.spec.ts

+ 13 - 0
src/callstack/index.ts

@@ -33,6 +33,14 @@ export class Callstack extends Panel {
       })
     );
 
+    header.toolbar.addItem(
+      'terminate',
+      new CommandToolbarButton({
+        commands: commands.registry,
+        id: commands.terminate
+      })
+    );
+
     header.toolbar.addItem(
       'step-over',
       new CommandToolbarButton({
@@ -128,6 +136,11 @@ export namespace Callstack {
      */
     continue: string;
 
+    /**
+     * The terminate command ID.
+     */
+    terminate: string;
+
     /**
      * The next / stepOver command ID.
      */

+ 17 - 0
src/index.ts

@@ -53,6 +53,8 @@ export namespace CommandIDs {
 
   export const debugContinue = 'debugger:continue';
 
+  export const terminate = 'debugger:terminate';
+
   export const next = 'debugger:next';
 
   export const stepIn = 'debugger:stepIn';
@@ -291,6 +293,20 @@ const main: JupyterFrontEndPlugin<IDebugger> = {
       }
     });
 
+    commands.addCommand(CommandIDs.terminate, {
+      label: 'Terminate',
+      caption: 'Terminate',
+      iconClass: 'jp-MaterialIcon jp-StopIcon',
+      isEnabled: () => {
+        return service.isThreadStopped();
+      },
+      execute: async () => {
+        await service.stop();
+        await service.start();
+        commands.notifyCommandChanged();
+      }
+    });
+
     commands.addCommand(CommandIDs.next, {
       label: 'Next',
       caption: 'Next',
@@ -350,6 +366,7 @@ const main: JupyterFrontEndPlugin<IDebugger> = {
         const callstackCommands = {
           registry: commands,
           continue: CommandIDs.debugContinue,
+          terminate: CommandIDs.terminate,
           next: CommandIDs.next,
           stepIn: CommandIDs.stepIn,
           stepOut: CommandIDs.stepOut

+ 1 - 0
tests/src/debugger.spec.ts

@@ -24,6 +24,7 @@ describe('Debugger', () => {
       callstackCommands: {
         registry,
         continue: '',
+        terminate: '',
         next: '',
         stepIn: '',
         stepOut: ''