jesseduffield.lazygit/pkg/commands/patch
Stefan Haller f7e26fec4e Make the patch-building secondary pane's space remove the right lines, disable its discard
The focused-main-view rework made the secondary pane actionable, but the old
patch-building explorer's secondary was inert, so its actions were never thought
through. Pressing space there routed through the same toggle handler as the main
pane, resolving the selection against the secondary's diff and mapping it to
patch-builder indices by line number. But the secondary shows the *aggregated*
custom patch, which renumbers included additions whenever an earlier addition in
the same hunk is excluded (Transform recomputes each hunk's +start). So the
shifted number resolved to the wrong line in the original diff — often adding an
unrelated line instead of removing the selected one.

Resolve the secondary selection by its *ordinal* among the change lines shown
instead: the custom-patch view renders exactly the included change lines in
order, so the k-th change line of a file is that file's k-th included change line
(PatchBuilder.IncludedChangeLineIndices), independent of the renumbering. Space
in the secondary now only ever removes, mirroring how space in the staging view's
staged pane unstages.

Discarding from the commit (the remove key) makes no sense in the custom-patch
preview — it would act on lines shown only as the patch, and space already
removes them — so it's disabled there.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-08 12:59:00 +02:00
..
format.go Export PatchLine.isChange 2025-07-04 10:14:35 +02:00
hunk.go Recover diff-line identity by parsing the buffer, behind a swappable seam 2026-08-08 12:58:59 +02:00
parse.go Recover diff-line identity by parsing the buffer, behind a swappable seam 2026-08-08 12:58:59 +02:00
patch.go Recover diff-line identity by parsing the buffer, behind a swappable seam 2026-08-08 12:58:59 +02:00
patch_builder.go Make the patch-building secondary pane's space remove the right lines, disable its discard 2026-08-08 12:59:00 +02:00
patch_builder_test.go Add identity-based line accessors to PatchBuilder 2026-08-08 12:59:00 +02:00
patch_line.go Fix selection after staging an added line 2026-03-19 16:57:53 +01:00
patch_test.go Recover diff-line identity by parsing the buffer, behind a swappable seam 2026-08-08 12:58:59 +02:00
transform.go Show renamed files in the custom patch builder 2026-07-04 13:05:09 +02:00