Closed Bug 1557632 Opened 5 years ago Closed 5 years ago

In editor mode, Ctrl+Enter doesn't evaluate sometimes depending on the cursor position

Categories

(DevTools :: Console, defect, P1)

defect

Tracking

(firefox69 fixed)

RESOLVED FIXED
Firefox 69
Tracking Status
firefox69 --- fixed

People

(Reporter: nchevobbe, Assigned: nchevobbe)

References

Details

(Whiteboard: [console-editor-mvp])

Attachments

(1 file)

Steps to reproduce

  1. Open the console with editor mode turned on
  2. Type the following
x = 10;
x++;
x;
  1. Place the cursor on the second line, after the first +:
x = 10;
x+|+;
x;
  1. Hit Ctrl + Enter (Cmd + Enter on OSX)

Expected results

The expression is evaluated (I see 11 in the output).

Actual results

The expression isn't evaluated

This is because of this line devtools/client/webconsole/components/JSTerm.js#201 :

!Debugger.isCompilableUnit(this.getInputValueBeforeCursor())

In other words, we check that the input before the cursor position is valid JS, which is erroneous, as we should check the whole input (_getValue).
But I'm even wondering if we should do this check at all: this feature is done to ensure we can still it enter and have a new line entered when in non-editor mode (for example, if you started to type function {.
In editor mode, we may have a long input string, and if at some point we missed a quote, it might be hard to find it. So maybe we want to always execute in editor mode, and there will be an error message in the output.

Whiteboard: [console-editor-mvp]
Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED
Priority: P2 → P1

In the regular webconsole input, on Enter, we check that the
input is a compilable unit, so the user don't accidentally
execute an incomplete snippet.
In the editor mode, the user will have to use Ctrl/Cmd + Enter to
execute, so we don't have to worry about Enter (it will simply
append a new line).
And since the user might deal with a large number of characters,
we don't want to prevent them to execute. If it's malformed, they
will get an error in the output and can fix their input easily, since
it wasn't cleared.

The patch adds a test to ensure this work as expected.

Pushed by nchevobbe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/7428c7656117
Don't check if input is compilable unit on Ctrl+Enter. r=Honza.
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 69
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: