stkb / Rewrap

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

Valid comments with unusual comment markers are not wrapped correctly. #362

Open benblank opened 1 year ago

benblank commented 1 year ago

While working on a shell script, I discovered that Rewrap doesn't behave the way I expected — when I use ### to start a comment instead of just # (I'm using the former as kind of a makeshift "doc comment"), triggering a rewrap simply does nothing at all. A quick test in JavaScript shows a different, but equally undesirable, behavior. The following examples were created by setting the editor mode to the referenced language, typing the unwrapped text, and then triggering the "Rewrap/Unwrap Text At Column…" command, with width 40, on each line.

Shell script Unusual comment markers cause the entire line to be ignored. **Before** ```sh # This is a long comment which will get wrapped. ## This is another long comment, but it will NOT get wrapped! ### This is another long comment which won't get wrapped. ``` **After** ```sh # This is a long comment which will get # wrapped. ## This is another long comment, but it will NOT get wrapped! ### This is another long comment which won't get wrapped. ```
JavaScript Unusual comment markers are wrapped, but in an undesirable manner — in this example, the four-slash comment both has its comment marker truncated on wrapped lines and also omits the space after the comment marker. (Presumably, the entire line is interpreted as "a three-slash comment without a space after the comment marker", from which point of view the exhibited behavior is perfectly consistent.) **Before** ```javascript // This is a long comment which will get wrapped correctly. /// This is another long comment which will also get wrapped correctly. //// But this is a long comment which will NOT get wrapped correctly! ``` **After** ```javascript // This is a long comment which will get // wrapped correctly. /// This is another long comment which /// will also get wrapped correctly. //// But this is a long comment which ///will NOT get wrapped correctly! ```

Environment