diff --git a/devtools/client/debugger/new/src/utils/breakpoint/breakpointPositions.js b/devtools/client/debugger/new/src/utils/breakpoint/breakpointPositions.js index b5046cb111fa..f4e6d5b6a594 100644 --- a/devtools/client/debugger/new/src/utils/breakpoint/breakpointPositions.js +++ b/devtools/client/debugger/new/src/utils/breakpoint/breakpointPositions.js @@ -5,19 +5,18 @@ * file, You can obtain one at . */ import { comparePosition } from "../location"; -import type { - BreakpointPositions, - SourceLocation, - Position -} from "../../types"; +import { getSelectedLocation } from "../source-maps"; +import type { BreakpointPositions, SourceLocation } from "../../types"; export function findPosition( positions: ?BreakpointPositions, - location: Position | SourceLocation + location: SourceLocation ) { if (!positions) { return null; } - return positions.find(pos => comparePosition(pos.location, location)); + return positions.find(pos => + comparePosition(getSelectedLocation(pos, location), location) + ); } diff --git a/devtools/client/debugger/new/src/utils/source-maps.js b/devtools/client/debugger/new/src/utils/source-maps.js index 0090c7478228..dd70b22528a9 100644 --- a/devtools/client/debugger/new/src/utils/source-maps.js +++ b/devtools/client/debugger/new/src/utils/source-maps.js @@ -6,7 +6,6 @@ import { isOriginalId } from "devtools-source-map"; import { getSource } from "../selectors"; -import { isGenerated } from "../utils/source"; import type { SourceLocation, MappedLocation, Source } from "../types"; import typeof SourceMaps from "../../packages/devtools-source-map/src"; @@ -104,9 +103,15 @@ export function isOriginalSource(source: ?Source) { export function getSelectedLocation( mappedLocation: MappedLocation, - selectedSource: ?Source + context: ?(Source | SourceLocation) ): SourceLocation { - return selectedSource && isGenerated(selectedSource) - ? mappedLocation.generatedLocation - : mappedLocation.location; + if (!context) { + return mappedLocation.location; + } + + // $FlowIgnore + const sourceId = context.sourceId || context.id; + return isOriginalId(sourceId) + ? mappedLocation.location + : mappedLocation.generatedLocation; }