News for hackers. Stuff that matters.
Re:A Prettier JavaScript Formatter by flukus on Tuesday January 10, 2017 @08:58PM (#13371140)
Why does the formatter need to solve this and not the editor? The editor has more information available to it, like the present screen space.
Re:A Prettier JavaScript Formatter by pcwalton on Tuesday January 10, 2017 @10:05PM (#13371416)
> Why does the formatter need to solve this and not the editor? The editor has more information available to it, like the present screen space.

Because making the line wrapping nice requires deep syntax-aware editor integration. Most languages try to be at least somewhat plain-text-editor-friendly.

Re:A Prettier JavaScript Formatter by flukus on Tuesday January 10, 2017 @10:17PM (#13371455)
> Because making the line wrapping nice requires deep syntax-aware editor integration.

Why does it need to be syntax aware?

Re:A Prettier JavaScript Formatter by eddyb on Tuesday January 10, 2017 @11:34PM (#13371777)
Think what happens when you break a line comment (or a string, in languages where it can't span several lines). And that's an easy example at that.
Re:A Prettier JavaScript Formatter by flukus on Wednesday January 11, 2017 @12:05AM (#13371892)
What happens? Nothing as far as I'm aware. The code is still one line.
Re:A Prettier JavaScript Formatter by sobani on Wednesday January 11, 2017 @02:53AM (#13372454)
> Because making the line wrapping nice requires deep syntax-aware editor integration.

'nice' is the key word here

Re:A Prettier JavaScript Formatter by Manishearth on Tuesday January 10, 2017 @09:59PM (#13371395)
Theoretically, an editor could. I have yet to see one that does this well. Most do dumb wrapping, with no language sensitivity.

I think it's just a matter of programmer habit now -- folks expect their editor to mirror the code without formatting tweaks.

It gets confusing when you realize that programmers may insert their own indentation and wrapping, and sometimes you want to make this part of the actual file, and sometimes you want to remove it before serializing.

Re:A Prettier JavaScript Formatter by flukus on Tuesday January 10, 2017 @10:16PM (#13371448)
I've been pretty happy with vim and "set breakindent" where the broken line is indented to the parent one. I pretty frequently work with small views of a file.
Re:A Prettier JavaScript Formatter by Sophistifunk on Tuesday January 10, 2017 @10:19PM (#13371471)
I wish more people would realise this.