microsoft / microsoft/vscode-java-pack

Feature request, java language formatter selective comment text reflow

Open
#891 6 comments 0 reactions 1 assignee View on GitHub

@CsCherrYY is already working on this.

Since Feb 11, 2022.

ai-triaged enhancement feature-request formatter
Dominant language
TypeScript
Stars
352
Forks
166
Avg merge
17h 47m
Merged PRs (30d)
32

Description

Suggestion

I noticed the java formatter will treat different types of comments different ways. For example, it automatically reflows text on the /* */ comments, but it doesn't have the same behavior on // comments where it will preserve even its own previous line breaks, which can get annoying. Is there perhaps a way we could do something like have it not reflow // comments at all and only reflow /* */ comments? Or perhaps even ignore // comments altogether for formatting purposes while still adjusting /* */ comments?

Use Cases

When I want to simply comment out code, but leave its indentation intact for later purposes, I like to just use the ctrl-/ shortcut, but formatting the code using alt-shift-f removes the indentations. I realize there is an extension feature to disable this behavior, but unfortunately, that also disables the text reflow in the javadoc comments as well as some other comments where I'd like the reflow to happen automatically upon formatting.

Examples

So for example, if I comment out this code:

// if (true) {
//     return true;
// }

I would like that formatting to be retained. However, I'd also like it if the autoformat would automatically re-flow comments that are so long that they extend beyond the window width, and I could mark those with /* */. So for example, it would auto re-flow this sentence like this:

  /*
   * I would like that formatting to be retained. However, I'd also like it if the autoformat
   * would automatically re-flow comments that are so long that they extend beyond the window
   * width, and I could mark those with . So for example, it would re-flow this sentence like
   * this:
   */

#204

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.