summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-12-20 13:01:41 +0100
committerStefan Haller <stefan@haller-berlin.de>2024-03-09 10:00:44 +0100
commit379a6f1922aaa9f2eb7ec27a8818fbacd1db0057 (patch)
tree356dc2684451d764ab3d7aea179a834552be5c50
parentcede0214009888e32027beb212b63e30e77d29e7 (diff)
Save and restore the unwrapped description
When preserving the commit message (when cancelling a commit), and later restoring it, use the unwrapped description.
-rw-r--r--pkg/gui/controllers.go4
-rw-r--r--pkg/gui/controllers/commit_message_controller.go2
-rw-r--r--pkg/gui/controllers/helpers/commits_helper.go29
3 files changed, 21 insertions, 14 deletions
diff --git a/pkg/gui/controllers.go b/pkg/gui/controllers.go
index 30caae930..1dbf9b7d7 100644
--- a/pkg/gui/controllers.go
+++ b/pkg/gui/controllers.go
@@ -38,10 +38,14 @@ func (gui *Gui) resetHelpersAndControllers() {
getCommitDescription := func() string {
return strings.TrimSpace(gui.Views.CommitDescription.TextArea.GetContent())
}
+ getUnwrappedCommitDescription := func() string {
+ return strings.TrimSpace(gui.Views.CommitDescription.TextArea.GetUnwrappedContent())
+ }
commitsHelper := helpers.NewCommitsHelper(helperCommon,
getCommitSummary,
setCommitSummary,
getCommitDescription,
+ getUnwrappedCommitDescription,
setCommitDescription,
)
diff --git a/pkg/gui/controllers/commit_message_controller.go b/pkg/gui/controllers/commit_message_controller.go
index c52a8038f..ef95dffe0 100644
--- a/pkg/gui/controllers/commit_message_controller.go
+++ b/pkg/gui/controllers/commit_message_controller.go
@@ -100,7 +100,7 @@ func (self *CommitMessageController) handleCommitIndexChange(value int) error {
self.c.Helpers().Commits.SetMessageAndDescriptionInView(self.context().GetHistoryMessage())
return nil
} else if currentIndex == context.NoCommitIndex {
- self.context().SetHistoryMessage(self.c.Helpers().Commits.JoinCommitMessageAndDescription())
+ self.context().SetHistoryMessage(self.c.Helpers().Commits.JoinCommitMessageAndUnwrappedDescription())
}
validCommit, err := self.setCommitMessageAtIndex(newIndex)
diff --git a/pkg/gui/controllers/helpers/commits_helper.go b/pkg/gui/controllers/helpers/commits_helper.go
index 8691518cd..cd90790a3 100644
--- a/pkg/gui/controllers/helpers/commits_helper.go
+++ b/pkg/gui/controllers/helpers/commits_helper.go
@@ -16,10 +16,11 @@ type ICommitsHelper interface {
type CommitsHelper struct {
c *HelperCommon
- getCommitSummary func() string
- setCommitSummary func(string)
- getCommitDescription func() string
- setCommitDescription func(string)
+ getCommitSummary func() string
+ setCommitSummary func(string)
+ getCommitDescription func() string
+ getUnwrappedCommitDescription func() string
+ setCommitDescription func(string)
}
var _ ICommitsHelper = &CommitsHelper{}
@@ -29,14 +30,16 @@ func NewCommitsHelper(
getCommitSummary func() string,
setCommitSummary func(string),
getCommitDescription func() string,
+ getUnwrappedCommitDescription func() string,
setCommitDescription func(string),
) *CommitsHelper {
return &CommitsHelper{
- c: c,
- getCommitSummary: getCommitSummary,
- setCommitSummary: setCommitSummary,
- getCommitDescription: getCommitDescription,
- setCommitDescription: setCommitDescription,
+ c: c,
+ getCommitSummary: getCommitSummary,
+ setCommitSummary: setCommitSummary,
+ getCommitDescription: getCommitDescription,
+ getUnwrappedCommitDescription: getUnwrappedCommitDescription,
+ setCommitDescription: setCommitDescription,
}
}
@@ -53,11 +56,11 @@ func (self *CommitsHelper) SetMessageAndDescriptionInView(message string) {
self.c.Contexts().CommitMessage.RenderCommitLength()
}
-func (self *CommitsHelper) JoinCommitMessageAndDescription() string {
- if len(self.getCommitDescription()) == 0 {
+func (self *CommitsHelper) JoinCommitMessageAndUnwrappedDescription() string {
+ if len(self.getUnwrappedCommitDescription()) == 0 {
return self.getCommitSummary()
}
- return self.getCommitSummary() + "\n" + self.getCommitDescription()
+ return self.getCommitSummary() + "\n" + self.getUnwrappedCommitDescription()
}
func (self *CommitsHelper) SwitchToEditor() error {
@@ -154,7 +157,7 @@ func (self *CommitsHelper) HandleCommitConfirm() error {
func (self *CommitsHelper) CloseCommitMessagePanel() error {
if self.c.Contexts().CommitMessage.GetPreserveMessage() {
- message := self.JoinCommitMessageAndDescription()
+ message := self.JoinCommitMessageAndUnwrappedDescription()
self.c.Contexts().CommitMessage.SetPreservedMessage(message)
} else {