stkb / Rewrap

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

Git Commit Message Wraps lines at 50 characters instead of 72 #395

Open theory opened 7 months ago

theory commented 7 months ago

[Moving from microsoft/vscode#206480]

Since at least VScode v1.86.1, Git Commit Message mode has two wrap columns: 50 characters for the subject line (the first lone line of the buffer), and 72 characters for the body (all other lines). When using rewrap, it wraps body lines at 50 characters instead of 72. This GIF illustrates the issue:

309910186-f1226575-335f-4b55-8681-6955655820ca

I presume this is because the 50 character wrap column comes first, so is the default choice for rewrap. But the 72 wrap column is the more important one for Git commit messages, since the subject line is only a single line, but the body can be quite long.

VS Code version: Code 1.87.0 (Universal) (019f4d1419fbc8219a181fab7892ebccf7ee29a2, 2024-02-27T23:42:56.944Z) OS version: Darwin arm64 23.3.0

theory commented 6 months ago

I was able to work around this issue by making the 50 character ruler secondary with this config:

  "[git-commit]": {
    "editor.rulers": [72, 50],
    "editor.wordWrap": "on"
  },

The default is "editor.rulers": [50, 72],; I guess rewrap relies on the first ruler setting, which makes sense.

jmhodges commented 4 months ago

Would love for rewrap to handle this itself! Def hit me for a while before I realized this was the problem and even then spent a lot of time googling to realize it was the commit title vs summary.

Or maybe we (I?) should make a ticket against vscode for the ruler length swap?

jmhodges commented 4 months ago

Oh, you know, that workaround isn't consistent. If you tell Rewrap to run when the line is between 50 and 72 characters, it wraps at the 50 character limit. It only wraps at the 72 character limit when the line is longer then 72 characters.

I suspect Rewrap will have to learn a bit more about what mode its in? I know that's a gross hack, but I'm not sure what else to do

Or just always pick the longest?

theory commented 4 months ago

Would be nice if the VSCode rulers had an API to tell you which context you were in…

Peeja commented 2 months ago

As a workaround, this seems to work just fine, it just duplicates information that's already configured in the ruler setting:

  "[git-commit]": {
    "rewrap.wrappingColumn": 72
  },

Having rewrap.wrappingColumn set turns off the ruler-aware wrapping altogether. Considering that number doesn't really ever change, the duplication's not so bad. 😄