debugger icon indicating copy to clipboard operation
debugger copied to clipboard

[Breakpoints] show line text

Open darkwing opened this issue 9 years ago • 15 comments

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:

breakpointdetail

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.

darkwing avatar Oct 08 '17 13:10 darkwing

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.

jasonLaster avatar Oct 08 '17 15:10 jasonLaster

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 avatar Oct 08 '17 15:10 jasonLaster

@jasonLaster YES! This would be amazing! 👍

darkwing avatar Oct 11 '17 22:10 darkwing

/claim

jordanch avatar Oct 12 '17 19:10 jordanch

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!

claim avatar Oct 12 '17 19:10 claim

Thanks @jordanch, just clarifying. This issue is just for showing the line. Please ask us questions in slack if something comes up!

jasonLaster avatar Oct 12 '17 19:10 jasonLaster

Yes, indeed. Thanks @jasonLaster

jordanch avatar Oct 12 '17 21:10 jordanch

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

jasonLaster avatar Nov 04 '17 21:11 jasonLaster

Hi @jasonLaster - it's going, albeit slowly!

Thank you! I received and accepted, woot!

jordanch avatar Nov 06 '17 06:11 jordanch

Great!

Out of curiosity, what have you learned so far about breakpoints? It's a complicated part of the project :)

jasonLaster avatar Nov 06 '17 16:11 jasonLaster

@jordanch are you still on it? It's no problem if you don't resume working on it

nyrosmith avatar Jan 06 '18 11:01 nyrosmith

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

jordanch avatar Jan 06 '18 15:01 jordanch

Hey @jordanch how's it going? can we help anywhere?

jasonLaster avatar Jan 25 '18 02:01 jasonLaster

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?

jordanch avatar Feb 26 '18 07:02 jordanch

closing this as we'll have a new issue for the awesome new breakpoints pane

jasonLaster avatar Feb 27 '18 20:02 jasonLaster