Bug 1630449 - Avoid refreshing editor on selectedFrame change r=jlast

Differential Revision: https://phabricator.services.mozilla.com/D71131
This commit is contained in:
David Walsh 2020-04-16 01:32:20 +00:00
parent 8e9361fe24
commit b9a2cdbdc0
2 changed files with 20 additions and 10 deletions

View File

@ -4,8 +4,13 @@
// @flow
import { getSymbols, getSource } from "../../selectors";
import type { ThreadContext, Frame } from "../../types";
import {
getSymbols,
getSource,
getSelectedFrame,
getCurrentThread,
} from "../../selectors";
import type { ThreadContext } from "../../types";
import type { ThunkArgs } from "../types";
// a is an ast location with start and end positions (line and column).
@ -23,9 +28,18 @@ function inHouseContainsPosition(a: Object, b: Object) {
return startsBefore && endsAfter;
}
export function highlightCalls(cx: ThreadContext, frame: ?Frame) {
export function highlightCalls(cx: ThreadContext) {
return async function({ dispatch, getState, parser, client }: ThunkArgs) {
if (!frame || !cx) {
if (!cx) {
return;
}
const frame = await getSelectedFrame(
getState(),
getCurrentThread(getState())
);
if (!frame) {
return;
}

View File

@ -39,7 +39,6 @@ import {
getThreadContext,
getSkipPausing,
getInlinePreview,
getSelectedFrame,
getHighlightedCalls,
} from "../../selectors";
@ -91,7 +90,6 @@ import type {
SourceLocation,
SourceWithContent,
ThreadContext,
Frame,
HighlightedCalls as highlightedCallsType,
} from "../../types";
@ -115,7 +113,6 @@ export type Props = {
isPaused: boolean,
skipPausing: boolean,
inlinePreviewEnabled: boolean,
selectedFrame: ?Frame,
highlightedCalls: ?highlightedCallsType,
// Actions
@ -339,8 +336,8 @@ class Editor extends PureComponent<Props, State> {
commandKeyDown = (e: KeyboardEvent) => {
const { key } = e;
if (this.props.isPaused && key === "Meta") {
const { cx, selectedFrame, highlightCalls } = this.props;
highlightCalls(cx, selectedFrame);
const { cx, highlightCalls } = this.props;
highlightCalls(cx);
}
};
@ -723,7 +720,6 @@ const mapStateToProps = state => {
isPaused: getIsPaused(state, getCurrentThread(state)),
skipPausing: getSkipPausing(state),
inlinePreviewEnabled: getInlinePreview(state),
selectedFrame: getSelectedFrame(state, getCurrentThread(state)),
highlightedCalls: getHighlightedCalls(state, getCurrentThread(state)),
};
};