debugger icon indicating copy to clipboard operation
debugger copied to clipboard

[breakpoints] shift+click should add a disabled breakpoint

Open jasonLaster opened this issue 7 years ago • 9 comments

When the user shift+clicks in the gutter, the debugger should create a disabled breakpoint. Currently it creates an enabled breakpoint.

This is a good starting off spot

diff --git a/src/actions/breakpoints/index.js b/src/actions/breakpoints/index.js
index 830b39a64..4aa386967 100644
--- a/src/actions/breakpoints/index.js
+++ b/src/actions/breakpoints/index.js
@@ -385,7 +385,11 @@ export function toggleBreakpointsAtLine(line: number, column?: number) {
   };
 }

-export function addOrToggleDisabledBreakpoint(line: number, column?: number) {
+export function addOrToggleDisabledBreakpoint(
+  line: number,
+  column?: number,
+  shouldDisable
+) {
   return ({ dispatch, getState, client, sourceMaps }: ThunkArgs) => {
     const selectedSource = getSelectedSource(getState());

@@ -411,7 +415,8 @@ export function addOrToggleDisabledBreakpoint(line: number, column?: number) {
         sourceId: selectedSource.id,
         sourceUrl: selectedSource.url,
         line: line,
-        column: column
+        column: column,
+        enabled: !shouldDisable
       })
     );
   };
diff --git a/src/components/Editor/index.js b/src/components/Editor/index.js
index 7227c11d3..e0cf932a4 100644
--- a/src/components/Editor/index.js
+++ b/src/components/Editor/index.js
@@ -404,7 +404,7 @@ class Editor extends PureComponent<Props, State> {
     }

     if (ev.shiftKey) {
-      return addOrToggleDisabledBreakpoint(sourceLine);
+      return addOrToggleDisabledBreakpoint(sourceLine, ev.shiftKey);
     }
:

jasonLaster avatar Jan 07 '19 03:01 jasonLaster

I would like to work on this. should I alter the existing function or override?

baronKilljoy avatar Jan 07 '19 04:01 baronKilljoy

/claim

baronKilljoy avatar Jan 07 '19 04:01 baronKilljoy

Thanks for claiming the issue! :wave:

Here are some links for getting setup, contributing, and developing. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.

:fox_face: Debugger team!

claim avatar Jan 07 '19 04:01 claim

@baronKilljoy altering the existing function should do :)

AnshulMalik avatar Jan 07 '19 07:01 AnshulMalik

My idea is to use the preexisting disabled property. However, it kepts being set to false. Am I doing something obviously wrong. change1 change2

baronKilljoy avatar Jan 08 '19 10:01 baronKilljoy

@AnshulMalik @jasonLaster the shouldDisable wasn't working (since you would have to shift+click to get to this function it was either nothing or undefined). This approach worked but its different than your recommendation. change1 change2

baronKilljoy avatar Jan 08 '19 20:01 baronKilljoy

@AnshulMalik @jasonLaster it looks like the breakpoint will have to be fully initialized then disabled.

baronKilljoy avatar Jan 12 '19 06:01 baronKilljoy

@baronKilljoy I was talking to @jasonLaster and he suggested sort of a fusion between your original PR and mine:

export function createDisabledBreakpoint(location: SourceLocation) {
  return async ({ dispatch, getState, sourceMaps, client }: ThunkArgs) => {
    const generatedLocation = await getGeneratedLocation(
      state,
      source,
      location,
      sourceMaps
    );
    const symbols = getSymbols(getState(), source);
    const astLocation = await getASTLocation(source, symbols, newLocation);

    const originalText = getTextAtPosition(source, location);
    const text = getTextAtPosition(generatedSource, newGeneratedLocation);

    const breakpoint = createBreakpoint(breakpointPosition, {
      ...options,
      disabled: true,
      astLocation,
      originalText,
      text
    });
  };
}

Care to give it a try? :)

darkwing avatar Feb 06 '19 21:02 darkwing

https://bugzilla.mozilla.org/show_bug.cgi?id=1543999

darkwing avatar Apr 12 '19 14:04 darkwing