Skip to content

Commit 84ca73f

Browse files
committed
fix: don't strip newlines by default
Fixes #2
1 parent b29a5c3 commit 84ca73f

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ This is a Visual Studio Code extension that formats git commit messages in the s
2626
* Configure whether you want validation and quick fixes for commit types in the subject line:
2727
- `gitCommit.subjectLine.lint.enabled`: (default: `false`)
2828
- `gitCommit.subjectLine.lint.types` (default: `feat:`, `fix:` [and other Conventional Commit types](https://www.conventionalcommits.org/en/v1.0.0/))
29+
* Configure whether you want the formatter to strip multiple successive newlines:
30+
- `gitCommit.collapseMultipleEmptyLines.enabled` (default: `false`)
2931

3032
## Development
3133

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "git-commit-formatter",
33
"displayName": "Git Commit Message Formatter",
4-
"version": "1.0.0",
4+
"version": "1.1.0",
55
"description": "Format commit messages from the source control input box",
66
"main": "./out/extension.js",
77
"scripts": {
@@ -44,6 +44,11 @@
4444
"default": false,
4545
"markdownDescription": "%gitCommit.subjectLine.lint.enabled%"
4646
},
47+
"gitCommit.collapseMultipleEmptyLines.enabled": {
48+
"type": "boolean",
49+
"default": false,
50+
"markdownDescription": "%gitCommit.collapseMultipleEmptyLines.enabled%"
51+
},
4752
"gitCommit.subjectLine.lint.types": {
4853
"type": "array",
4954
"default": ["fix", "feat", "build", "chore", "ci", "docs", "style", "refactor", "perf", "test", "revert"],

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"gitCommit.subjectLine.overflowStrategy": "Controls how to format subject lines that exceed `#git.inputValidationSubjectLength#`.",
3+
"gitCommit.collapseMultipleEmptyLines.enabled": "Controls whether multiple empty lines are stripped from the commit message during formatting.",
34
"gitCommit.subjectLine.lint.enabled": "Controls whether to show a warning when the subject line of a commit message does not start with a type.",
45
"gitCommit.subjectLine.lint.types": "Controls which types a subject line of a commit message can start with when `#gitCommitFormat.subjectLine.lint.enabled#` is `true`."
56
}

src/gitCommitMessageFormatter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class GitCommitMessageFormatter implements vscode.OnTypeFormattingEditPro
1111
vscode.workspace.onDidChangeConfiguration((e) => {
1212
if (e.affectsConfiguration("git.inputValidationLength")
1313
|| e.affectsConfiguration("git.inputValidationSubjectLength")
14-
|| e.affectsConfiguration("gitCommit.subjectLine.overflowStrategy")) {
14+
|| e.affectsConfiguration("gitCommit")) {
1515
this._formatter = new CommitMessageFormatter(this._getFormatterOptions());
1616
}
1717
});
@@ -54,7 +54,7 @@ export class GitCommitMessageFormatter implements vscode.OnTypeFormattingEditPro
5454
lineLength: gitConfig.get("inputValidationLength", 72),
5555
subjectLength: gitConfig.get("inputValidationSubjectLength", 50),
5656
subjectMode: vscode.workspace.getConfiguration("gitCommit").get("subjectLine.overflowStrategy", "split"),
57-
collapseMultipleEmptyLines: true
57+
collapseMultipleEmptyLines: vscode.workspace.getConfiguration("gitCommit").get("collapseMultipleEmptyLines.enabled", false),
5858
}
5959
}
6060

0 commit comments

Comments
 (0)