jesseduffield.lazygit/pkg/gui/controllers/helpers
Stefan Haller cd50c79ae4 Preserve the commit message correctly even if the description has blank lines
There are two possible fixes for this bug, and they differ in behavior when
rewording a commit. The one I chose here always splits at the first line feed,
which means that for an improperly formatted commit message such as this one:

   This is a very long multi-line subject,
   which you shouldn't really use in git.

   And this is the body (we call it "description" in lazygit).

we split after the first line instead of after the first paragraph. This is
arguably not what the original author meant, but splitting after the first
paragraph doesn't really work well in lazygit, because we would try to put both
lines into the one-line subject field of the message panel, and you'd only see
the second and not even know that there are more.

The other potential fix would have been to join subject and description with two
line feeds instead of one in JoinCommitMessageAndDescription; this would have
fixed our bug in the same way, but would result in splitting the above message
after the second line instead of the first. I think that's worse, so I decided
for the first fix.

While we're at it, simplify the code a little bit; strings.Cut is documented to
return (s, "") when the separator is not found, so there's no need to do this on
our side.

We do have to trim spaces on the description now, to support the regular reword
case where subject and body are separated by a blank line.
2024-01-09 14:31:53 +01:00
..
amend_helper.go Improve prompts when amending commits 2023-09-01 18:55:16 +02:00
app_status_helper.go Add WithWaitingStatusSync 2023-12-09 15:28:40 +01:00
bisect_helper.go split context common from helper common 2023-04-30 13:19:53 +10:00
branches_helper.go Allow deleting remote tags/branches from local tag/branch views (#2738) 2023-08-10 17:39:26 +10:00
cherry_pick_helper.go Allow cherry-picking commits during a rebase 2023-09-18 10:50:19 +02:00
commits_helper.go Preserve the commit message correctly even if the description has blank lines 2024-01-09 14:31:53 +01:00
confirmation_helper.go Remove unused WithLoaderPanel code 2023-09-20 13:30:49 +02:00
credentials_helper.go Handle pending actions properly in git commands that require credentials 2023-07-08 22:54:52 +10:00
diff_helper.go Move IgnoreWhitespaceInDiffView to AppState, and persist it when it changes 2023-07-31 11:41:55 +02:00
files_helper.go use 'suspend' instead of 'editInTerminal' internally 2023-08-09 22:03:58 +10:00
gpg_helper.go Use an interface for tasks instead of a concrete struct 2023-07-10 17:12:21 +10:00
helpers.go Add WithInlineStatus helper function 2023-10-08 18:45:36 +02:00
host_helper.go standardise helper args 2023-04-30 13:19:53 +10:00
inline_status_helper.go Fall back to WithWaitingStatus if item is scrolled out of view 2023-12-10 16:03:25 +01:00
merge_and_rebase_helper.go Use DisabledReason for rebasing a branch onto itself 2023-09-18 10:20:23 +02:00
merge_conflicts_helper.go Fix race condition 2023-05-16 21:01:38 +10:00
mode_helper.go Add WithWaitingStatusSync 2023-12-09 15:28:40 +01:00
patch_building_helper.go Don't pass ignoreWhitespace to git commands 2023-09-04 17:50:49 +02:00
record_directory_helper.go split context common from helper common 2023-04-30 13:19:53 +10:00
refresh_helper.go Add a sort order menu for local branches 2023-12-27 15:25:29 +01:00
refs_helper.go Add a sort order menu for local branches 2023-12-27 15:25:29 +01:00
repos_helper.go Remove sync mutex 2023-10-08 18:45:36 +02:00
search_helper.go When refreshing models, re-apply active filter for the corresponding view 2023-10-10 08:37:30 +02:00
snake_helper.go split context common from helper common 2023-04-30 13:19:53 +10:00
staging_helper.go Don't pass ignoreWhitespace to git commands 2023-09-04 17:50:49 +02:00
sub_commits_helper.go feat: add jump-to-panel label setting 2023-09-09 09:45:08 +02:00
suggestions_helper.go Standardise on using lo for slice functions 2023-07-30 18:51:23 +10:00
tags_helper.go Allow force-tagging if tag exists 2023-07-31 11:38:52 +02:00
update_helper.go Use an interface for tasks instead of a concrete struct 2023-07-10 17:12:21 +10:00
upstream_helper.go standardise helper args 2023-04-30 13:19:53 +10:00
upstream_helper_test.go Standardise on using lo for slice functions 2023-07-30 18:51:23 +10:00
view_helper.go standardise helper args 2023-04-30 13:19:53 +10:00
window_arrangement_helper.go Add tests for window arrangement code 2023-12-09 11:53:52 +01:00
window_arrangement_helper_test.go Add tests for window arrangement code 2023-12-09 11:53:52 +01:00
window_helper.go Return only visible views from TopViewInWindow 2023-12-10 15:57:51 +01:00
working_tree_helper.go Extract a WithEnsureCommitableFiles function 2023-08-29 09:10:59 +02:00
worktree_helper.go Use fields rather than methods on worktrees 2023-07-30 18:35:24 +10:00