mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 01:05:45 +00:00
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:
parent
695115479a
commit
cbc8307003
@ -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)
|
||||
);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user