@@ -12,6 +12,7 @@ import {
1212} from "../../utils/breakpoint" ;
1313
1414import { getGeneratedLocation } from "../../utils/source-maps" ;
15+ import { getTextAtPosition } from "../../utils/source" ;
1516import { originalToGeneratedId } from "devtools-source-map" ;
1617import { getSource } from "../../selectors" ;
1718import type {
@@ -50,9 +51,17 @@ function createSyncData(
5051 pendingBreakpoint : PendingBreakpoint ,
5152 location : Location ,
5253 generatedLocation : Location ,
53- previousLocation : Location
54+ previousLocation : Location ,
55+ text : string ,
56+ originalText : string
5457) : BreakpointSyncData {
55- const overrides = { ...pendingBreakpoint , generatedLocation, id } ;
58+ const overrides = {
59+ ...pendingBreakpoint ,
60+ generatedLocation,
61+ id,
62+ text,
63+ originalText
64+ } ;
5665 const breakpoint = createBreakpoint ( location , overrides ) ;
5766
5867 assertBreakpoint ( breakpoint ) ;
@@ -71,10 +80,13 @@ export async function syncClientBreakpoint(
7180 assertPendingBreakpoint ( pendingBreakpoint ) ;
7281
7382 const source = getSource ( getState ( ) , sourceId ) ;
83+
7484 const generatedSourceId = sourceMaps . isOriginalId ( sourceId )
7585 ? originalToGeneratedId ( sourceId )
7686 : sourceId ;
7787
88+ const generatedSource = getSource ( getState ( ) , generatedSourceId ) ;
89+
7890 const { location, astLocation } = pendingBreakpoint ;
7991 const previousLocation = { ...location , sourceId } ;
8092
@@ -110,12 +122,17 @@ export async function syncClientBreakpoint(
110122 // send update only to redux
111123 if ( pendingBreakpoint . disabled || ( existingClient && isSameLocation ) ) {
112124 const id = pendingBreakpoint . disabled ? "" : existingClient . id ;
125+ const originalText = getTextAtPosition ( source , previousLocation ) ;
126+ const text = getTextAtPosition ( generatedSource , generatedLocation ) ;
127+
113128 return createSyncData (
114129 id ,
115130 pendingBreakpoint ,
116131 scopedLocation ,
117132 scopedGeneratedLocation ,
118- previousLocation
133+ previousLocation ,
134+ text ,
135+ originalText
119136 ) ;
120137 }
121138
@@ -145,11 +162,16 @@ export async function syncClientBreakpoint(
145162 newGeneratedLocation
146163 ) ;
147164
165+ const originalText = getTextAtPosition ( source , newLocation ) ;
166+ const text = getTextAtPosition ( generatedSource , newGeneratedLocation ) ;
167+
148168 return createSyncData (
149169 id ,
150170 pendingBreakpoint ,
151171 newLocation ,
152172 newGeneratedLocation ,
153- previousLocation
173+ previousLocation ,
174+ text ,
175+ originalText
154176 ) ;
155177}
0 commit comments