Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
clean up paused
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonLaster committed Aug 13, 2018
1 parent 76e923b commit fc38bf3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
9 changes: 2 additions & 7 deletions src/actions/pause/paused.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,10 @@ export function paused(pauseInfo: Pause) {
}

await dispatch(mapFrames());
const selectedFrame = getSelectedFrame(getState());

const selectedFrame = getSelectedFrame(getState());
if (selectedFrame) {
const visibleFrame = getVisibleSelectedFrame(getState());
const location =
visibleFrame && isGeneratedId(visibleFrame.location.sourceId)
? selectedFrame.generatedLocation
: selectedFrame.location;
await dispatch(selectLocation(location));
await dispatch(selectLocation(selectedFrame.location));
}

dispatch(togglePaneCollapse("end", false));
Expand Down
44 changes: 29 additions & 15 deletions src/actions/sources/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,12 @@ export function selectLocation(
// Preserve the current source map context (original / generated)
// when navigting to a new location.
const selectedSource = getSelectedSource(getState());
if (keepContext && selectedSource && isOriginalId(selectedSource.id)) {
location = await sourceMaps.getOriginalLocation(location);
if (
keepContext &&
selectedSource &&
isDifferentContext(selectedSource.id, location.sourceId)
) {
location = await getMappedLocation(getState(), sourceMaps, location);
source = getSourceFromId(getState(), location.sourceId);
}

Expand Down Expand Up @@ -186,20 +190,13 @@ export function jumpToMappedLocation(location: Location) {
return;
}

const source = getSource(getState(), location.sourceId);
let pairedLocation;
if (isOriginalId(location.sourceId)) {
pairedLocation = await getGeneratedLocation(
getState(),
source,
location,
sourceMaps
);
} else {
pairedLocation = await sourceMaps.getOriginalLocation(location, source);
}
const pairedLocation = await getMappedLocation(
getState(),
sourceMaps,
location
);

return dispatch(selectLocation({ ...pairedLocation }));
return dispatch(selectSpecificLocation({ ...pairedLocation }));
};
}

Expand All @@ -213,3 +210,20 @@ export function jumpToMappedSelectedLocation() {
await dispatch(jumpToMappedLocation(location));
};
}

async function getMappedLocation(state, sourceMaps, location) {
const source = getSource(state, location.sourceId);

if (isOriginalId(location.sourceId)) {
return getGeneratedLocation(state, source, location, sourceMaps);
}

return sourceMaps.getOriginalLocation(location, source);
}

function isDifferentContext(aId, bId) {
const aOriginal = isOriginalId(aId);
const bOriginal = isOriginalId(bId);

return (aOriginal && !bOriginal) || (!aOriginal && bOriginal);
}

0 comments on commit fc38bf3

Please sign in to comment.