Closed Bug 1206633 Opened 9 years ago Closed 2 years ago

pretty print broke for...of statement

Categories

(DevTools :: Source Editor, defect)

42 Branch
defect
Not set
major

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1674400

People

(Reporter: mozilla, Unassigned)

References

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.1; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; rv:11.0) like Gecko

Steps to reproduce:

1. Load javascript source file with the following code :
for (let tab of tabs) { *\r\n* [...] *\r\n* }
2. Press CTRL+P


Actual results:

Code is formatted like this : 
for (lettaboftabs) { [...]

The code won't work anymore


Expected results:

"let tab of tabs" should have not been touched
OS: Unspecified → Windows 7
Hardware: Unspecified → x86
Component: Untriaged → Developer Tools: Scratchpad
Severity: normal → major
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows 7 → All
Hardware: x86 → All
Summary: Scratchpad's indentation broke source code → pretty print broke for...of statement
Blocks: 965141
Component: Developer Tools: Scratchpad → Developer Tools: Source Editor
FWIW I see this in scratchpad but not in the debugger.
This patch solves the general problem where two name tokens weren't separated by a space in the output. The function isGetterOrSetter is no longer necessary because it's a special case of this problem.

Some minor cosmetic issues remain: this patch will output "for (let tab of[array])". Because "of" isn't a keyword, fixing that would require running a full parser or using imperfect heuristics such as turning "of" into a keyword in the whole argument.
Reiterating from https://bugzilla.mozilla.org/show_bug.cgi?id=1261971#c7,
this should go upstream to pretty-fast first.
https://github.com/mozilla/pretty-fast
Product: Firefox → DevTools

I submitted the issue upstream: https://github.com/mozilla/pretty-fast/issues/41

Nerixyz says:

This is already fixed (commit, test, snap), however the version on npm is out of date and thus is the version used in firefox.

Just tested and this works properly.
Likely to have been fixed by Bug 1674400

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: