From cede0214009888e32027beb212b63e30e77d29e7 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 19 Nov 2023 16:39:01 +0100 Subject: [PATCH] Add config for soft-wrapping the commit message body --- docs/Config.md | 2 ++ pkg/config/user_config.go | 8 +++++++- pkg/gui/views.go | 2 ++ schema/config.json | 10 ++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/Config.md b/docs/Config.md index 5b686fc19..4b26c5f84 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -92,6 +92,8 @@ git: useConfig: false commit: signOff: false + autoWrapCommitMessage: true # automatic WYSIWYG wrapping of the commit message as you type + autoWrapWidth: 72 # if autoWrapCommitMessage is true, the width to wrap to merging: # only applicable to unix users manualCommit: false diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index 9cb758259..6a4efe78a 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -236,6 +236,10 @@ type PagingConfig struct { type CommitConfig struct { // If true, pass '--signoff' flag when committing SignOff bool `yaml:"signOff"` + // Automatic WYSIWYG wrapping of the commit message as you type + AutoWrapCommitMessage bool `yaml:"autoWrapCommitMessage"` + // If autoWrapCommitMessage is true, the width to wrap to + AutoWrapWidth int `yaml:"autoWrapWidth"` } type MergingConfig struct { @@ -658,7 +662,9 @@ func GetDefaultConfig() *UserConfig { ExternalDiffCommand: "", }, Commit: CommitConfig{ - SignOff: false, + SignOff: false, + AutoWrapCommitMessage: true, + AutoWrapWidth: 72, }, Merging: MergingConfig{ ManualCommit: false, diff --git a/pkg/gui/views.go b/pkg/gui/views.go index 13caa9c7f..9fd775764 100644 --- a/pkg/gui/views.go +++ b/pkg/gui/views.go @@ -168,6 +168,8 @@ func (gui *Gui) createAllViews() error { gui.Views.CommitDescription.FgColor = theme.GocuiDefaultTextColor gui.Views.CommitDescription.Editable = true gui.Views.CommitDescription.Editor = gocui.EditorFunc(gui.commitDescriptionEditor) + gui.Views.CommitDescription.TextArea.AutoWrap = gui.c.UserConfig.Git.Commit.AutoWrapCommitMessage + gui.Views.CommitDescription.TextArea.AutoWrapWidth = gui.c.UserConfig.Git.Commit.AutoWrapWidth gui.Views.Confirmation.Visible = false gui.Views.Confirmation.Editor = gocui.EditorFunc(gui.promptEditor) diff --git a/schema/config.json b/schema/config.json index b95381302..44d8e0cb4 100644 --- a/schema/config.json +++ b/schema/config.json @@ -405,6 +405,16 @@ "signOff": { "type": "boolean", "description": "If true, pass '--signoff' flag when committing" + }, + "autoWrapCommitMessage": { + "type": "boolean", + "description": "Automatic WYSIWYG wrapping of the commit message as you type", + "default": true + }, + "autoWrapWidth": { + "type": "integer", + "description": "If autoWrapCommitMessage is true, the width to wrap to", + "default": 72 } }, "additionalProperties": false,