[breakpoints] shift+click should add a disabled breakpoint
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);
}
:
I would like to work on this. should I alter the existing function or override?
/claim
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!
@baronKilljoy altering the existing function should do :)
My idea is to use the preexisting disabled property. However, it kepts being set to false. Am I doing something obviously wrong.

@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.

@AnshulMalik @jasonLaster it looks like the breakpoint will have to be fully initialized then disabled.
@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? :)
https://bugzilla.mozilla.org/show_bug.cgi?id=1543999