Closed Bug 2001893 Opened 1 month ago Closed 1 month ago

"Autoclose brackets" prevents entering multi-line function body

Categories

(DevTools :: Console, defect)

Firefox 145
defect

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: michael.wycombe, Unassigned)

References

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:145.0) Gecko/20100101 Firefox/145.0

Steps to reproduce:

Using Inspect tool, console tab to type in a valid constructor function definition from and example

Actual results:

Entered the following:
function Person(name) {
this.name = name;
} (FF supplied this automatically to complete the function definition.

As soon as I type in this.name = name; (with or without the trailing <;>) the function definition is <complete> and return <undefined>

If I remove the trailing <}> that FF console gratuitously provides and was able to add another property to the constructor function definition.

It works as expected with MS Edge & Chrome.

Expected results:

When the constructor function definition is at this point:

function Person(name) {
this.name = name;^
}
with my cursor located at <^> I expected to be able to hit enter and add another property definition (which is how it work on MS Edge & Chrome).
FF just closes out the function definition and returns <undefined>.
FF should allow me to press <Enter> when at the <^> point and get a new line to continue entering properties.

I turned of auto-complete setting in the console but the trailing <}> was still added by the FF console

Thank you for reporting.
This is caused by the "Autoclose brackets" behavior, which automatically enters the closing "}" when you enter the opening "{".

https://firefox-source-docs.mozilla.org/devtools-user/settings/index.html#editor-preferences

Autoclose brackets
Determines whether typing an opening character like [ or { will cause the editor to insert the matching closing character ] or } for you.

Meanwhile, you can get the same behavior by turning it off, from the Settings.

Status: UNCONFIRMED → NEW
Component: Untriaged → Console
Ever confirmed: true
Product: Firefox → DevTools
Summary: Javascript function definition issue → "Autoclose brackets" prevents entering multi-line function body

Also if you want more control when writing multiline scripts you can enable the "multi-line editor mode" (it's the icon on the right of the input).
Otherwise, as Arai said this behavior is driven by the "autoclose brackets" option.

Interestingly, Chrome offers a similar option in their DevTools, but it only applies to script editing and not to the console input.

We have Bug 1427981 to provide hints about what Enter is about to do, I think that's the best course of action here.

Status: NEW → RESOLVED
Closed: 1 month ago
Resolution: --- → WONTFIX
See Also: → 1427981
You need to log in before you can comment on or make changes to this bug.