-
Notifications
You must be signed in to change notification settings - Fork 758
Refactor Breakpoints to be location symmetric #3294
Refactor Breakpoints to be location symmetric #3294
Conversation
src/actions/breakpoints.js
Outdated
const { sourceId } = selectedLocation; | ||
|
||
if (bp) { | ||
// NOTE: it's possible the breakpoint has slid to a column |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use the equalize location util!
src/actions/breakpoints.js
Outdated
}; | ||
} | ||
|
||
export function toggleBreakpointDisabledStatus(line) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i like this, might need a simpler name like "toggleDisabledBreakpoint"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice direction!
src/actions/breakpoints.js
Outdated
|
||
const { sourceId } = selectedLocation; | ||
|
||
if (!bp) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wonder if we can avoid this somehow... 🤔
@@ -476,75 +475,6 @@ class Editor extends PureComponent { | |||
return !!this.cbPanel; | |||
} | |||
|
|||
toggleBreakpoint(line, column = undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 niiice
@@ -661,44 +591,6 @@ class Editor extends PureComponent { | |||
}); | |||
} | |||
|
|||
renderBreakpoints() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woooo!
Codecov Report
@@ Coverage Diff @@
## master #3294 +/- ##
==========================================
+ Coverage 48.46% 48.92% +0.46%
==========================================
Files 102 105 +3
Lines 4288 4319 +31
Branches 891 893 +2
==========================================
+ Hits 2078 2113 +35
+ Misses 2210 2206 -4
Continue to review full report at Codecov.
|
6eb8bee
to
b2f407c
Compare
@@ -127,7 +133,6 @@ export function disableBreakpoint(location: Location) { | |||
const action = { | |||
type: "DISABLE_BREAKPOINT", | |||
breakpoint: bp, | |||
disabled: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, not being used...
source: "function foo2(x, y) {\n return x + y;\n}", | ||
contentType: "text/javascript" | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps there's a better way to keep this dummy data...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could it make sense to start using a factory library?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah - that might be a nice cleanup in a separate PR.
selectedSource: getSelectedSource(state) | ||
}), | ||
dispatch => bindActionCreators(actions, dispatch) | ||
)(Breakpoints); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
editor.setGutterMarker( | ||
showSourceText(editor, selectedSource.toJS()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is important for making sure that we're updating the correct codemirror document.
} | ||
|
||
/* | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should include a quick description
src/selectors/visibleBreakpoints.js
Outdated
: breakpoint.location; | ||
} | ||
|
||
export default function getVisibleBreakpoints(state: OuterState) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a quick comment to explain how this is used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this so that we can check if a breakpoint is also represented in a generated file? can we use it in all cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will get the breakpoints for a file at the "correct" location regardless of original / generated
@@ -24,7 +24,7 @@ add_task(function*() { | |||
yield addBreakpoint(dbg, mainSrc, 4); | |||
is(getBreakpoints(getState()).size, 1, "One breakpoint exists"); | |||
ok( | |||
getBreakpoint(getState(), { sourceId: mainSrc.id, line: 4 }), | |||
getBreakpoint(getState(), { sourceId: mainSrc.id, line: 4, column: 2 }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure why this changed :/
It is probably alright though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might be a regression - before we were making sure that we didn't turn line breakpoints into column breakpoints...
@@ -14,8 +13,7 @@ export function firstString(...args) { | |||
|
|||
export function locationMoved(location, newLocation) { | |||
return ( | |||
location.line !== newLocation.line || | |||
(location.column != null && location.column !== newLocation.column) | |||
location.line !== newLocation.line || location.column !== newLocation.column |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a nice clean up
: breakpoint.location; | ||
|
||
const sameLine = location.line === line + 1; | ||
const sameLine = breakpoint.location.line === line + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i love these cleanups.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work so far!
} | ||
|
||
if (bp) { | ||
// NOTE: it's possible the breakpoint has slid to a column |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to slide a breakpoint to a column if the user is expecting a line breakpoint?
source: "function foo2(x, y) {\n return x + y;\n}", | ||
contentType: "text/javascript" | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could it make sense to start using a factory library?
return null; | ||
} | ||
|
||
return dom.div( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the Breakpoint component returns null; so, do we need to wrap it in a div, or just return null, with the mapping done in the body of the function?
@@ -1,47 +1,45 @@ | |||
import { showMenu } from "devtools-launchpad"; | |||
|
|||
export default function GutterMenu({ | |||
bp, | |||
breakpoint, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
return isGeneratedId(sourceId); | ||
} | ||
|
||
function getColumn(column, selectedSource) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this pattern better than keeping the selectors in the reducer. maybe we could have a folder structure here:
selectors/
|- breakpoints/
|- index.js
|- atLocation.js
src/selectors/visibleBreakpoints.js
Outdated
: breakpoint.location; | ||
} | ||
|
||
export default function getVisibleBreakpoints(state: OuterState) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this so that we can check if a breakpoint is also represented in a generated file? can we use it in all cases?
@@ -24,7 +24,7 @@ add_task(function*() { | |||
yield addBreakpoint(dbg, mainSrc, 4); | |||
is(getBreakpoints(getState()).size, 1, "One breakpoint exists"); | |||
ok( | |||
getBreakpoint(getState(), { sourceId: mainSrc.id, line: 4 }), | |||
getBreakpoint(getState(), { sourceId: mainSrc.id, line: 4, column: 2 }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might be a regression - before we were making sure that we didn't turn line breakpoints into column breakpoints...
: breakpoint.location; | ||
|
||
const sameLine = location.line === line + 1; | ||
const sameLine = breakpoint.location.line === line + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 nice!
b2f407c
to
28a8e09
Compare
28a8e09
to
2df507c
Compare
Summary of Changes
This is a follow up refactor. The goal is to provide some abstractions so that BPs are better represented in the components: