jesseduffield.lazygit/pkg/integration/tests/patch_building
Stefan Haller e9c4425df6 Discard the selected diff line(s) from the focused main view
Wire the focused main view's `d` binding to a DiscardSelection action on the
side panel beneath, the discard counterpart of the primary action. As with
stage/toggle, what discard means is the panel's business:

- the files panel discards from the working tree, mirroring the staging
  view's `d` — reverse-apply not cached on the unstaged side (destructive, so
  confirmed), reverse-apply cached on the staged side (i.e. unstage);
- the commit panels (commit files, and the whole-commit diff of the local
  commits / sub-commits / stash panels) remove the selected lines from the
  commit via a rebase, mirroring the patch builder's "discard lines from
  commit" — building a one-off patch from the selection and deleting it.

The commit-discard backend and its guard are shared free functions in
patch_building_from_main_view.go, paralleling the patch toggle. Discarding
from a commit is only possible on a local branch, so DiscardSelection grows a
disabled-reason companion on the FocusedMainViewActions interface: the `d`
binding is greyed with a reason on stash and other-branch sub-commits (never
rebaseable) and while a rebase is in progress, exactly as the patch builder
greys it. The files panel is always available (a zero-context diff is the one
error it reports inline, matching the staging view).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-08 12:59:00 +02:00
..
apply.go Always render diffs to the main/secondary context pair, even for files 2025-04-21 18:03:18 +02:00
apply_in_reverse.go Always render diffs to the main/secondary context pair, even for files 2025-04-21 18:03:18 +02:00
apply_in_reverse_with_conflict.go Always render diffs to the main/secondary context pair, even for files 2025-04-21 18:03:18 +02:00
apply_with_modified_file_conflict.go Stage affected unstaged files when applying or reverting a patch 2025-07-02 16:19:06 +02:00
apply_with_modified_file_no_conflict.go Stage affected unstaged files when applying or reverting a patch 2025-07-02 16:19:06 +02:00
build_from_main_view.go Build a custom patch from the focused main view of a commit's files 2026-08-08 12:59:00 +02:00
build_from_whole_commit_main_view.go Build a custom patch from the commits / sub-commits / stash main views 2026-08-08 12:59:00 +02:00
build_multi_file_from_whole_commit_main_view.go Build a custom patch from the commits / sub-commits / stash main views 2026-08-08 12:59:00 +02:00
copy_renamed_file_diff.go Show renamed files in the custom patch builder 2026-07-04 13:05:09 +02:00
discard_lines_from_commit.go Allow discarding lines from patch directly 2026-03-07 20:47:20 +11:00
discard_lines_from_commit_main_view.go Discard the selected diff line(s) from the focused main view 2026-08-08 12:59:00 +02:00
edit_line_in_patch_building_panel.go Adjust line number for working copy when editing a line 2025-01-07 17:46:51 +01:00
move_range_to_index.go Always render diffs to the main/secondary context pair, even for files 2025-04-21 18:03:18 +02:00
move_to_earlier_commit.go Remove obsolete git version restrictions 2025-07-09 12:18:57 +02:00
move_to_earlier_commit_from_added_file.go Mention which command is continued in PromptToContinueRebase 2025-04-20 15:53:17 +02:00
move_to_index.go Always render diffs to the main/secondary context pair, even for files 2025-04-21 18:03:18 +02:00
move_to_index_from_added_file_with_conflict.go Mention which command is continued in PromptToContinueRebase 2025-04-20 15:53:17 +02:00
move_to_index_part_of_adjacent_added_lines.go Bump gocui 2025-01-07 17:34:30 +01:00
move_to_index_partial.go Enable hunk staging mode by default 2025-08-01 10:35:16 +02:00
move_to_index_with_conflict.go Mention which command is continued in PromptToContinueRebase 2025-04-20 15:53:17 +02:00
move_to_index_with_modified_file.go Drop stash when successfully unstashing files after moving patch to index 2025-07-02 16:19:06 +02:00
move_to_index_works_even_if_noprefix_is_set.go Always render diffs to the main/secondary context pair, even for files 2025-04-21 18:03:18 +02:00
move_to_later_commit.go Add a root item ("/") if files at top level have changed 2025-03-21 08:04:58 +01:00
move_to_later_commit_partial_hunk.go Add a root item ("/") if files at top level have changed 2025-03-21 08:04:58 +01:00
move_to_new_commit.go Add custom patch command "Move patch into new commit before the original commit" 2025-05-10 18:57:28 +02:00
move_to_new_commit_before.go Remove obsolete git version restrictions 2025-07-09 12:18:57 +02:00
move_to_new_commit_from_added_file.go Add custom patch command "Move patch into new commit before the original commit" 2025-05-10 18:57:28 +02:00
move_to_new_commit_from_deleted_file.go Add custom patch command "Move patch into new commit before the original commit" 2025-05-10 18:57:28 +02:00
move_to_new_commit_in_last_commit_of_stacked_branch.go Make integration tests using commits more robust 2026-07-09 11:56:27 +02:00
move_to_new_commit_partial_hunk.go Add custom patch command "Move patch into new commit before the original commit" 2025-05-10 18:57:28 +02:00
remove_from_commit.go Always render diffs to the main/secondary context pair, even for files 2025-04-21 18:03:18 +02:00
remove_parts_of_added_file.go Fix custom patch operations on added files 2024-06-23 12:40:31 +02:00
rename_similarity_threshold_change.go Show renamed files in the custom patch builder 2026-07-04 13:05:09 +02:00
renamed_file_partial.go Show renamed files in the custom patch builder 2026-07-04 13:05:09 +02:00
renamed_file_whole.go Show renamed files in the custom patch builder 2026-07-04 13:05:09 +02:00
reset_patch_built_from_main_view.go Build a custom patch from the commits / sub-commits / stash main views 2026-08-08 12:59:00 +02:00
reset_with_escape.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
select_all_files.go Add a root item ("/") if files at top level have changed 2025-03-21 08:04:58 +01:00
select_direcories_sharing_prefix.go Fix multi-selection of files with common prefix not working in commit files panel 2026-07-28 18:14:58 +02:00
specific_selection.go Enable hunk staging mode by default 2025-08-01 10:35:16 +02:00
start_new_patch.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
toggle_directory.go Filter file views rather than search 2026-03-07 20:04:31 +01:00
toggle_range.go Add a root item ("/") if files at top level have changed 2025-03-21 08:04:58 +01:00