stkb / Rewrap

Rewrap extension for VSCode and Visual Studio
https://marketplace.visualstudio.com/items/stkb.rewrap
Other
499 stars 58 forks source link

PHPDoc tags sometimes break #372

Open lkrms opened 1 year ago

lkrms commented 1 year ago

Thanks for your work on this excellent extension. It makes my life easier every day :)

I'm finally reporting (rather than continuing to work around my one issue with Rewrap, especially given the cleanup that is sometimes required after using it to reflow PHPDoc comments.

When working in PHP, I have rulers at 80, 120 and 0, and regularly rewrap entire files after editing documentation. It's impressive that Rewrap keeps PHP docblocks (mostly) intact, but I've found that when the first token after a tag is too long to keep on the same line, it's dropped to the next one and stays there at all three widths. Adjacent tags are unwrapped correctly.

It would be great if text with no leading @ were moved to the line above whenever it can be accommodated (this wouldn't break anything as far as PSR-5 is concerned, because descriptions are always expected to be Markdown) and/or if the first token immediately after a tag were never moved to the line below. The current output sometimes renders the tag invalid.

For example (no irony intended; I just happen to be working on some PHPDoc parsing code of my own!):

/**
 * A valid PHPDoc tag
 *
 * @link https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc.md#53-tags
 */

After rewrapping, I get this, and the URL never moves back to @link:

/**
 * A valid PHPDoc tag
 *
 * @link
 * https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc.md#53-tags
 */

Thanks again for all of the time you've put into this project!