Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatter fails to format uglified files #10126

Open
dbaeumer opened this issue Aug 4, 2016 · 2 comments
Open

Formatter fails to format uglified files #10126

dbaeumer opened this issue Aug 4, 2016 · 2 comments
Labels
Domain: Formatter The issue relates to the built-in formatter Help Wanted You can do this Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue
Milestone

Comments

@dbaeumer
Copy link
Member

dbaeumer commented Aug 4, 2016

TypeScript Version: 1.8.10

I use vscode from the Command Palette to format a javascript file uglified by uglify-js, but it failed. It not format code correctly, and only format partially.

source file
2016-07-12 4 47 08

sublime jsFormat formated
2016-07-12 4 47 29

vscode formated
2016-07-12 4 47 45

You see, It seems like, vscode only add some spaces around brackets, letters, commas etc.

See microsoft/vscode#8914 (comment) and the discussion below for more details. The provided traces clearly show that the tsserver only returns white space (" ") changes. No insertion of new lines.

@mhegazy
Copy link
Contributor

mhegazy commented Dec 14, 2016

The formatter favors keeping functions on the same line when the user specified. this is to suppport things like:

var o { p: function () { }, c: function () { } };

the result is for a minified file, you get one long line, with some spaces added, but no new lines.

I suppose we could add an option to add newlines always after {.

@mhegazy mhegazy added Suggestion An idea for TypeScript Domain: Formatter The issue relates to the built-in formatter Help Wanted You can do this labels Dec 14, 2016
@mhegazy mhegazy added this to the Community milestone Dec 14, 2016
@mhegazy mhegazy added the VS Code Tracked There is a VS Code equivalent to this issue label Dec 16, 2016
@sdwarwick
Copy link

Not sure if #23829 is the same problem, but you'll notice in that report that there is no code highlighting happening either. Not having a setting that enables the same behavior as commonly available command line tools is very unfortunate. Is there any plan to provide this level of functionality, or an alternative approach available?

@RyanCavanaugh RyanCavanaugh modified the milestones: Community, Backlog Mar 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Formatter The issue relates to the built-in formatter Help Wanted You can do this Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

No branches or pull requests

4 participants