From b9a2cdbdc0918a1a7fd0dfde277d79279632763c Mon Sep 17 00:00:00 2001 From: David Walsh Date: Thu, 16 Apr 2020 01:32:20 +0000 Subject: [PATCH] Bug 1630449 - Avoid refreshing editor on selectedFrame change r=jlast Differential Revision: https://phabricator.services.mozilla.com/D71131 --- .../src/actions/pause/highlightCalls.js | 22 +++++++++++++++---- .../debugger/src/components/Editor/index.js | 8 ++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/devtools/client/debugger/src/actions/pause/highlightCalls.js b/devtools/client/debugger/src/actions/pause/highlightCalls.js index f6ba33ac1f47..83c58d53efd4 100644 --- a/devtools/client/debugger/src/actions/pause/highlightCalls.js +++ b/devtools/client/debugger/src/actions/pause/highlightCalls.js @@ -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; } diff --git a/devtools/client/debugger/src/components/Editor/index.js b/devtools/client/debugger/src/components/Editor/index.js index f1c9ab123891..6addea091e5f 100644 --- a/devtools/client/debugger/src/components/Editor/index.js +++ b/devtools/client/debugger/src/components/Editor/index.js @@ -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 { 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)), }; };