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

Commit e8fdb9a

Browse files
committed
Fix a couple of stepping typeErrors (#5680)
1 parent ae91179 commit e8fdb9a

File tree

5 files changed

+32
-5
lines changed

5 files changed

+32
-5
lines changed

src/actions/breakpoints/tests/syncing.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ jest.mock("../../../utils/prefs", () => ({
88
expressions: [],
99
pendingBreakpoints: {}
1010
},
11+
features: {
12+
replay: false
13+
},
1114
clear: jest.fn()
1215
}));
1316

src/actions/pause/commands.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
// @flow
77

8-
import { isPaused, getSelectedSource, getTopFrame } from "../../selectors";
8+
import { isPaused, getSource, getTopFrame } from "../../selectors";
99
import { PROMISE } from "../utils/middleware/promise";
1010
import { getNextStep } from "../../workers/parser";
1111
import { addHiddenBreakpoint } from "../breakpoints";
@@ -162,9 +162,13 @@ function hasAwait(source, pauseLocation) {
162162
return false;
163163
}
164164

165-
const snippet = source.text
166-
.split("\n")
167-
[line - 1].slice(column - 50, column + 50);
165+
const lineText = source.text.split("\n")[line - 1];
166+
167+
if (!lineText) {
168+
return false;
169+
}
170+
171+
const snippet = lineText.slice(column - 50, column + 50);
168172

169173
return !!snippet.match(/(yield|await)/);
170174
}
@@ -184,7 +188,7 @@ export function astCommand(stepType: CommandType) {
184188
if (stepType == "stepOver") {
185189
// This type definition is ambiguous:
186190
const frame: any = getTopFrame(getState());
187-
const source = getSelectedSource(getState()).toJS();
191+
const source = getSource(getState(), frame.location.sourceId);
188192

189193
if (source && hasAwait(source, frame.location)) {
190194
const nextLocation = await getNextStep(source.id, frame.location);

src/actions/tests/pending-breakpoints.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ jest.mock("../../utils/prefs", () => ({
1616
expressions: [],
1717
pendingBreakpoints: {}
1818
},
19+
features: {
20+
replay: false
21+
},
1922
clear: jest.fn()
2023
}));
2124

src/components/Editor/Breakpoint.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
44

55
// @flow
6+
67
import React, { Component } from "react";
78
import ReactDOM from "react-dom";
89
import classnames from "classnames";

src/reducers/replay.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
44

55
// @flow
6+
import { features } from "../utils/prefs";
67

78
/**
89
* Breakpoints reducer
@@ -26,6 +27,10 @@ const defaultFrameScopes = {
2627
};
2728

2829
function update(state: ReplayState = initialState(), action: any): ReplayState {
30+
if (!features.replay) {
31+
return state;
32+
}
33+
2934
switch (action.type) {
3035
case "TRAVEL_TO": {
3136
return { ...state, position: action.position };
@@ -59,6 +64,11 @@ function addScopes(state: ReplayState, action: any) {
5964
const { frame, status, value } = action;
6065
const selectedFrameId = frame.id;
6166
const instance = state.history[state.position];
67+
68+
if (!instance) {
69+
return state;
70+
}
71+
6272
const pausedInst = instance.paused;
6373

6474
const generated = {
@@ -86,6 +96,11 @@ function mapScopes(state: ReplayState, action: any) {
8696
const { frame, status, value } = action;
8797
const selectedFrameId = frame.id;
8898
const instance = state.history[state.position];
99+
100+
if (!instance) {
101+
return state;
102+
}
103+
89104
const pausedInst = instance.paused;
90105

91106
const original = {
@@ -115,6 +130,7 @@ function evaluateExpression(state, action) {
115130
if (!instance) {
116131
return state;
117132
}
133+
118134
const prevExpressions = instance.expressions || [];
119135
const expression = { input, value };
120136
const expressions = [...prevExpressions, expression];

0 commit comments

Comments
 (0)