[Breakpoints] show line text
This is just a quick idea but ....
If you look at the breakpoint listing, it doesn't say much. It shows you the file name and the line but, unless you're currently at that breakpoint, you don't really know what code is there.
What if we did something like this:
What we'd need to feel for here is if this would cause too much bloat and scrolling to the breakpoint list. I, however, would find this super useful.
Thanks for filing @darkwing, i see this as part of the larger Breakpoints pane UX work we can do this quarter. I definitely agree we should show users the line the breakpoint is on.
In the past we've talked about grouping breakpoints by file as well. This might be a good time to bring this conversation back.
With that said, we probably shouldn't block showing breakpoint lines on a decision over grouping by file. We should probably go ahead and land breakpoint lines first regardless as there is a decent amount of technical work there too.
here is a gist to help get the ball rolling:
diff --git a/src/actions/breakpoints/addBreakpoint.js b/src/actions/breakpoints/addBreakpoint.js
index 2dfbb5c..5e19e30 100644
--- a/src/actions/breakpoints/addBreakpoint.js
+++ b/src/actions/breakpoints/addBreakpoint.js
@@ -7,6 +7,7 @@ import {
} from "../../utils/breakpoint";
import { getSource } from "../../selectors";
import { getGeneratedLocation } from "../../utils/source-maps";
+import { getSourceLine } from "../../utils/source";
export default async function addBreakpoint(
getState,
@@ -26,6 +27,8 @@ export default async function addBreakpoint(
sourceMaps
);
+ const lineText = getSourceLine(source, location);
+
assertLocation(location);
assertLocation(generatedLocation);
@@ -57,7 +60,8 @@ export default async function addBreakpoint(
location: newLocation,
astLocation,
hitCount,
- generatedLocation: newGeneratedLocation
+ generatedLocation: newGeneratedLocation,
+ text: lineText
};
assertBreakpoint(newBreakpoint);
diff --git a/src/actions/breakpoints/syncBreakpoint.js b/src/actions/breakpoints/syncBreakpoint.js
index b00fc77..d1475ed 100644
--- a/src/actions/breakpoints/syncBreakpoint.js
+++ b/src/actions/breakpoints/syncBreakpoint.js
@@ -33,6 +33,9 @@ function createSyncData(
const overrides = { ...pendingBreakpoint, generatedLocation };
const breakpoint = createBreakpoint(location, overrides);
+ // we'll have to pass source in here
+ const lineText = getSourceLine(source, scopedLocation);
+
assertBreakpoint(breakpoint);
return { breakpoint, previousLocation };
}
diff --git a/src/utils/source.js b/src/utils/source.js
index 97ee400..689b431 100644
--- a/src/utils/source.js
+++ b/src/utils/source.js
@@ -246,6 +246,10 @@ function isLoaded(source: Source) {
return source.loadedState === "loaded";
}
+function getSourceLine(source, location) {
+ return source.text.split("\n")[location.line - 1];
+}
+
export {
isJavaScript,
isPretty,
@jasonLaster YES! This would be amazing! 👍
/claim
Thanks for claiming the issue! :wave:
Here are some link for getting setup, contributing, and development tips. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.
:fox_face: Debugger team!
Thanks @jordanch, just clarifying. This issue is just for showing the line. Please ask us questions in slack if something comes up!
Yes, indeed. Thanks @jasonLaster
Hey @jordanch just following up to see how it's going. Also, we invited you to our community team a couple weeks ago :) you should see the invite in your inbox
Hi @jasonLaster - it's going, albeit slowly!
Thank you! I received and accepted, woot!
Great!
Out of curiosity, what have you learned so far about breakpoints? It's a complicated part of the project :)
@jordanch are you still on it? It's no problem if you don't resume working on it
@nyrosmith
yeah, this is on my radar, im tackling it while learning redux in my Udacity course.
I apologize ahead of time for picking a difficult issue that has taken me some time to PR although I thought it a decent practical challenge!
I'm hoping to have something up in the next couple weeks.
Hey @jordanch how's it going? can we help anywhere?
Howsit @jasonLaster
Swamped @ work. This is still on my radar! Thing's will be slowing down here in a couple weeks and then I'll have more capacity. Cool?
closing this as we'll have a new issue for the awesome new breakpoints pane