Bug 1533489 - findBreakpoint should be context aware. r=loganfsmyth

Differential Revision: https://phabricator.services.mozilla.com/D22558

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jason Laster 2019-03-08 13:39:06 +00:00
parent 695115479a
commit cbc8307003
2 changed files with 16 additions and 12 deletions

View File

@ -5,19 +5,18 @@
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
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)
);
}

View File

@ -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;
}