1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-08 04:04:22 +02:00
lazygit/pkg/gui/controllers
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
..
helpers Preserve the commit message correctly even if the description has blank lines 2024-01-09 14:31:53 +01:00
attach.go
base_controller.go
basic_commits_controller.go Add command to open git difftool 2024-01-09 14:27:33 +01:00
bisect_controller.go
branches_controller.go Add a sort order menu for local branches 2023-12-27 15:25:29 +01:00
command_log_controller.go
commit_description_controller.go Add key binding for switching from the commit message panel to an editor 2023-08-21 10:03:34 +02:00
commit_message_controller.go Add key binding for switching from the commit message panel to an editor 2023-08-21 10:03:34 +02:00
commits_files_controller.go Add command to open git difftool 2024-01-09 14:27:33 +01:00
common.go
confirmation_controller.go
context_lines_controller.go Move diff context size from UserConfig to AppState 2023-09-05 13:55:30 +02:00
custom_command_action.go Standardise on using lo for slice functions 2023-07-30 18:51:23 +10:00
custom_patch_options_menu_action.go
diffing_menu_action.go
files_controller.go Add command to open git difftool 2024-01-09 14:27:33 +01:00
files_remove_controller.go Support custom keybindings for confirm discard 2023-08-25 08:50:05 -05:00
filter_controller.go
filtering_menu_action.go
git_flow_controller.go
global_controller.go
jump_to_side_window_controller.go
list_controller.go Add a mechanism to insert non-model items into list contexts 2023-08-29 08:04:47 +02:00
local_commits_controller.go Add WithWaitingStatusSync for reverting commits 2023-12-09 15:28:41 +01:00
menu_controller.go Add DisabledReason field to MenuItem 2023-09-18 10:15:11 +02:00
merge_conflicts_controller.go Moves log related translations into its own Tr.Log. namespace 2023-07-31 19:42:41 -04:00
options_menu_action.go Add Enabled func to Binding 2023-09-18 10:20:23 +02:00
patch_building_controller.go
patch_explorer_controller.go Pass UserConfig to checkScrollUp/Down instead of just the scrollOffMargin 2023-08-21 08:10:28 +02:00
quit_actions.go Update repo switch logic 2023-07-30 18:35:23 +10:00
reflog_commits_controller.go Don't pass ignoreWhitespace to git commands 2023-09-04 17:50:49 +02:00
remote_branches_controller.go Add a sort order menu for local branches 2023-12-27 15:25:29 +01:00
remotes_controller.go feat: add jump-to-panel label setting 2023-09-09 09:45:08 +02:00
screen_mode_actions.go Remove special code to rerender views on screen mode change 2023-10-16 09:03:07 +02:00
scroll_off_margin_test.go Add tests for scroll-off margin of zero 2023-08-21 08:10:28 +02:00
scroll_off_margin.go Add scrollOffEnabled config 2023-08-21 09:03:45 +02:00
search_controller.go
search_prompt_controller.go Add search history 2023-09-20 08:35:41 +03:00
side_window_controller.go
snake_controller.go
staging_controller.go
stash_controller.go Don't pass ignoreWhitespace to git commands 2023-09-04 17:50:49 +02:00
status_controller.go Pass "now" into utils.Loader 2023-10-16 09:03:07 +02:00
sub_commits_controller.go Don't pass ignoreWhitespace to git commands 2023-09-04 17:50:49 +02:00
submodules_controller.go Don't pass ignoreWhitespace to git commands 2023-09-04 17:50:49 +02:00
suggestions_controller.go
switch_to_diff_files_controller.go feat: add jump-to-panel label setting 2023-09-09 09:45:08 +02:00
switch_to_sub_commits_controller.go Add "Show divergence from upstream" entry to Upstream menu in branches panel 2023-08-29 08:16:40 +02:00
sync_controller.go Disallow pulling/pushing a branch while the branch is pushed or pulled 2023-10-08 18:45:36 +02:00
tags_controller.go Fix checking out a tag when a branch with the same name exists 2024-01-09 14:18:35 +01:00
toggle_whitespace_action.go Extract a SaveAppStateAndLogError function 2023-09-04 17:50:49 +02:00
types.go
undo_controller.go
vertical_scroll_controller.go
workspace_reset_controller.go Reset origin when clearing view 2023-08-08 22:01:43 +10:00
worktree_options_controller.go
worktrees_controller.go Use fields rather than methods on worktrees 2023-07-30 18:35:24 +10:00