Refactor Breakpoints to be location symmetric#3294
Conversation
| const { sourceId } = selectedLocation; | ||
|
|
||
| if (bp) { | ||
| // NOTE: it's possible the breakpoint has slid to a column |
There was a problem hiding this comment.
you can use the equalize location util!
| }; | ||
| } | ||
|
|
||
| export function toggleBreakpointDisabledStatus(line) { |
There was a problem hiding this comment.
i like this, might need a simpler name like "toggleDisabledBreakpoint"
|
|
||
| const { sourceId } = selectedLocation; | ||
|
|
||
| if (!bp) { |
There was a problem hiding this comment.
i wonder if we can avoid this somehow... 🤔
| return !!this.cbPanel; | ||
| } | ||
|
|
||
| toggleBreakpoint(line, column = undefined) { |
| }); | ||
| } | ||
|
|
||
| renderBreakpoints() { |
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
| const action = { | ||
| type: "DISABLE_BREAKPOINT", | ||
| breakpoint: bp, | ||
| disabled: true, |
There was a problem hiding this comment.
yup, not being used...
| source: "function foo2(x, y) {\n return x + y;\n}", | ||
| contentType: "text/javascript" | ||
| } | ||
| }; |
There was a problem hiding this comment.
perhaps there's a better way to keep this dummy data...
There was a problem hiding this comment.
could it make sense to start using a factory library?
There was a problem hiding this comment.
yeah - that might be a nice cleanup in a separate PR.
| selectedSource: getSelectedSource(state) | ||
| }), | ||
| dispatch => bindActionCreators(actions, dispatch) | ||
| )(Breakpoints); |
| const line = breakpoint.location.line - 1; | ||
|
|
||
| editor.setGutterMarker( | ||
| showSourceText(editor, selectedSource.toJS()); |
There was a problem hiding this comment.
This is important for making sure that we're updating the correct codemirror document.
| } | ||
|
|
||
| /* | ||
| * |
There was a problem hiding this comment.
I should include a quick description
| : breakpoint.location; | ||
| } | ||
|
|
||
| export default function getVisibleBreakpoints(state: OuterState) { |
There was a problem hiding this comment.
There should be a quick comment to explain how this is used
There was a problem hiding this comment.
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.
This will get the breakpoints for a file at the "correct" location regardless of original / generated
| 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.
not sure why this changed :/
It is probably alright though
There was a problem hiding this comment.
this might be a regression - before we were making sure that we didn't turn line breakpoints into column breakpoints...
| 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.
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.
i love these cleanups.
| } | ||
|
|
||
| if (bp) { | ||
| // NOTE: it's possible the breakpoint has slid to a column |
There was a problem hiding this comment.
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.
could it make sense to start using a factory library?
| return null; | ||
| } | ||
|
|
||
| return dom.div( |
There was a problem hiding this comment.
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?
|
|
||
| export default function GutterMenu({ | ||
| bp, | ||
| breakpoint, |
| return isGeneratedId(sourceId); | ||
| } | ||
|
|
||
| function getColumn(column, selectedSource) { |
There was a problem hiding this comment.
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
| : breakpoint.location; | ||
| } | ||
|
|
||
| export default function getVisibleBreakpoints(state: OuterState) { |
There was a problem hiding this comment.
is this so that we can check if a breakpoint is also represented in a generated file? can we use it in all cases?
| 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.
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; |
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: