Line wrap doesn't wrap comments
See original GitHub issueI’m inheriting a node.js app, and it’s ridden with code and comments that exceed 79 characters, so I executed the following on all files:
js-beautify -r -s 2 -a -j -B -w 79 -n --good-stuff <file>
When I run this on all files, I’m finding that there’s 379 lines in comments that aren’t wrapped in the application:
sed -n '/\(.\)\{80\}/p' <file>
If I put this into a file test.js
(and set the screen width to 79):
/*
* This is a test line that is more than seventy-nine characters in length, inc
luding the comment start and period.
* This is another line that is less than seventy-nine characters in length.
*
*/
var test = 'This is a test string that is more than seventy characters in lengt
h, even without the var declaration.';
And then I run js-beautify -r -s 2 -a -j -B -w 79 -n --good-stuff test.js
then the following is the modified file:
/*
* This is a test line that is more than seventy-nine characters in length, inc
luding the comment start and period.
* This is another line that is less than seventy-nine characters in length.
*
*/
var test =
'This is a test string that is more than seventy characters in length, even w
ithout the var declaration.';
It appears that long strings don’t get broken up either.
Is this intentional or a bug?
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Text Doesn't Wrap at Margin in Draft View - Word Ribbon Tips
Text Doesn't Wrap at Margin in Draft View · Display the Word Options dialog box. · Click Advanced at the left side of...
Read more >Word Wrap feature not working #108326 - GitHub
Issue Type: Bug. I attempted to use [alt]Z and [alt]z tp get word wrap to work. When this failed, I clecked on View...
Read more >Wrapping text automatically option doesn't seem to work
I've set Outlook's “Automatically wrap text at character” option to 40 instead of the default 76 but it doesn't appear to do anything....
Read more >In Word 2010, Comments do not wrap correctly.
When using comments and viewing them as balloons, the first line of text is always wrapped incorrectly. For example, it cuts words apart, ......
Read more >Wrapping and breaking text - CSS: Cascading Style Sheets
This guide explains the various ways in which overflowing text can be managed in CSS.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey, thanks for asking.
I agree #421 covers your feature request for comment formatting, but (as you pointed out) not the behavior you described for string formatting. Leaving this open makes.
(I’ve moved your examples into the first comment and cleaned up the thread a bit. )
Unfortunately, the beautifier uses a rather simplistic engine and focuses on rearranging whitespace around tokens, rather than on rearranging tokens themselves. The string formatting you suggest is more involved requiring rewriting of tokens themselves, not just rearranging whitespace. So, it is out of scope at this time. If the beautifier reaches sufficient sophistication to be able to do token modification and we get the line wrapping from “best effort” to fully baked, this would certainly be one of the first token modification features I’d look at adding.
Thanks!
Perhaps a desired output could be:
Or similar.