Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.82 KB | None | 0 0
  1. diff --git a/src/actions/tests/pending-breakpoints.spec.js b/src/actions/tests/pending-breakpoints.spec.js
  2. index c381039..3fa989f 100644
  3. --- a/src/actions/tests/pending-breakpoints.spec.js
  4. +++ b/src/actions/tests/pending-breakpoints.spec.js
  5. @@ -94,6 +94,19 @@ describe("when adding breakpoints", () => {
  6. expect(pendingBps.get(breakpointLocationId2)).toMatchSnapshot();
  7. });
  8.  
  9. + it("hidden breakponts do not create pending bps", async () => {
  10. + const { dispatch, getState } = createStore(simpleMockThreadClient);
  11. +
  12. + await dispatch(actions.newSource(makeSource("foo")));
  13. + await dispatch(
  14. + actions.addBreakpoint(breakpoint1.location, { hidden: true })
  15. + );
  16. + const pendingBps = selectors.getPendingBreakpoints(getState());
  17. +
  18. + // should be null
  19. + expect(pendingBps.get(breakpointLocationId1)).toBe(null);
  20. + });
  21. +
  22. it("remove a corresponding pending breakpoint when deleting", async () => {
  23. const { dispatch, getState } = createStore(simpleMockThreadClient);
  24. await dispatch(actions.newSource(makeSource("foo")));
  25. diff --git a/src/reducers/pending-breakpoints.js b/src/reducers/pending-breakpoints.js
  26. index 0cd7419..be85711 100644
  27. --- a/src/reducers/pending-breakpoints.js
  28. +++ b/src/reducers/pending-breakpoints.js
  29. @@ -31,6 +31,7 @@ export type PendingBreakpointsState = {
  30. export function initialState(): Record<PendingBreakpointsState> {
  31. return makeRecord(
  32. ({
  33. + // this is where we load the pending breakpoints when the debugger opens
  34. pendingBreakpoints: restorePendingBreakpoints()
  35. }: PendingBreakpointsState)
  36. )();
  37. @@ -42,6 +43,11 @@ function update(
  38. ) {
  39. switch (action.type) {
  40. case "ADD_BREAKPOINT": {
  41. + if (action.breakpoint.hidden) {
  42. + return;
  43. + }
  44. +
  45. + // we could add an IF here so that we avoid adding hidden bps
  46. return addBreakpoint(state, action);
  47. }
  48.  
  49. @@ -61,7 +67,11 @@ function update(
  50. return updateBreakpoint(state, action);
  51. }
  52.  
  53. - case "REMOVE_BREAKPOINT": {
  54. + case "REMOVE_BREAKPOINT":
  55. + // we could add an IF here so that we no op hidden bps {
  56. + if (action.breakpoint.hidden) {
  57. + return;
  58. + }
  59. return removeBreakpoint(state, action);
  60. }
  61. }
  62. @@ -99,6 +109,8 @@ function syncBreakpoint(state, action) {
  63. function updateBreakpoint(state, action) {
  64. const { breakpoint } = action;
  65. const locationId = makePendingLocationId(breakpoint.location);
  66. +
  67. + // this is how we set the data to save for a bp
  68. const pendingBreakpoint = createPendingBreakpoint(breakpoint);
  69.  
  70. return state.setIn(["pendingBreakpoints", locationId], pendingBreakpoint);
  71. @@ -136,6 +148,7 @@ export function getPendingBreakpointsForSource(
  72. );
  73. }
  74.  
  75. +// this is where we load the pending breakpoints when the debugger opens
  76. function restorePendingBreakpoints() {
  77. return I.Map(prefs.pendingBreakpoints);
  78. }
  79. diff --git a/src/utils/bootstrap.js b/src/utils/bootstrap.js
  80. index 2e944d6..e16bd02 100644
  81. --- a/src/utils/bootstrap.js
  82. +++ b/src/utils/bootstrap.js
  83. @@ -73,6 +73,7 @@ export function teardownWorkers() {
  84. function updatePrefs(state) {
  85. const pendingBreakpoints = selectors.getPendingBreakpoints(state);
  86.  
  87. + // this is how we save pending bps
  88. if (prefs.pendingBreakpoints !== pendingBreakpoints) {
  89. prefs.pendingBreakpoints = pendingBreakpoints;
  90. }
  91. diff --git a/src/utils/breakpoint/index.js b/src/utils/breakpoint/index.js
  92. index b25c3c7..69d2306 100644
  93. --- a/src/utils/breakpoint/index.js
  94. +++ b/src/utils/breakpoint/index.js
  95. @@ -128,6 +128,7 @@ function createPendingLocation(location: PendingLocation) {
  96. return { sourceUrl, line, column };
  97. }
  98.  
  99. +// pending bps are basically bps, without a source id
  100. export function createPendingBreakpoint(bp: Breakpoint) {
  101. const pendingLocation = createPendingLocation(bp.location);
  102. const pendingGeneratedLocation = createPendingLocation(bp.generatedLocation);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement