In editor mode, Ctrl+Enter doesn't evaluate sometimes depending on the cursor position
Categories
(DevTools :: Console, defect, P1)
Tracking
(firefox69 fixed)
Tracking | Status | |
---|---|---|
firefox69 | --- | fixed |
People
(Reporter: nchevobbe, Assigned: nchevobbe)
References
Details
(Whiteboard: [console-editor-mvp])
Attachments
(1 file)
Steps to reproduce
- Open the console with editor mode turned on
- Type the following
x = 10;
x++;
x;
- Place the cursor on the second line, after the first
+
:
x = 10;
x+|+;
x;
- 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.
Updated•6 years ago
|
Assignee | ||
Updated•6 years ago
|
Assignee | ||
Comment 1•6 years ago
|
||
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.
Comment 3•6 years ago
|
||
bugherder |
Description
•