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

Commit 61a9bb5

Browse files
committed
[Preview] Empty Expression (#5475)
1 parent 41f55d4 commit 61a9bb5

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/client/firefox/commands.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,11 @@ function evaluateInFrame(frameId: string, script: Script) {
198198
}
199199

200200
function evaluate(
201-
script: Script,
201+
script: ?Script,
202202
{ frameId }: EvaluateParam = {}
203203
): Promise<mixed> {
204204
const params = frameId ? { frameActor: frameId } : {};
205-
if (!tabTarget || !tabTarget.activeConsole) {
205+
if (!tabTarget || !tabTarget.activeConsole || !script) {
206206
return Promise.resolve();
207207
}
208208

src/utils/editor/get-expression.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function tokenAtTextPosition(
3636
export function getExpressionFromCoords(cm: any, coord: Pos) {
3737
const token = tokenAtTextPosition(cm, coord);
3838
if (!token) {
39-
return;
39+
return null;
4040
}
4141

4242
let startHighlight = token.startColumn;
@@ -56,6 +56,11 @@ export function getExpressionFromCoords(cm: any, coord: Pos) {
5656
startHighlight = tokenBefore.startColumn;
5757
}
5858
const expression = line.substring(startHighlight, endHighlight);
59+
60+
if (!expression) {
61+
return null;
62+
}
63+
5964
const location = {
6065
start: { line: lineNumber, column: startHighlight },
6166
end: { line: lineNumber, column: endHighlight }

0 commit comments

Comments
 (0)