jesseduffield.lazygit/pkg/gui/types
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
..
common.go Let the post-stage reveal target a different pane than the one acted on 2026-08-08 12:59:00 +02:00
common_commands.go Don't refresh pull requests when checking out a local branch 2026-04-01 09:13:55 +02:00
context.go Discard the selected diff line(s) from the focused main view 2026-08-08 12:59:00 +02:00
diff_line_info.go Preserve the diff scroll and selection when the context size changes 2026-08-08 12:58:59 +02:00
keybindings.go Rename Key to Keys in Binding, KeybindingsOpts, and MenuItem 2026-05-25 15:18:18 +02:00
modes.go Add a "Mark commit as base commit for rebase" command 2023-07-31 08:41:41 +02:00
ref_range.go Move the Ref interface from gui/types to models 2025-07-31 15:21:34 +02:00
refresh.go Don't refuse a repo switch during a pure refresh 2026-07-20 17:07:39 +02:00
rendering.go Cleanup: add NewRunPtyTaskWithPrefix funxtion instead of setting Prefix manually 2025-07-02 16:15:19 +02:00
search_state.go Add search history 2023-09-20 08:35:41 +03:00
suggestion.go Set groundwork for better disabled reasons with range select 2024-01-23 13:03:37 +11:00
version_number.go Show popup message with breaking changes on startup 2024-03-12 13:27:14 +01:00
version_number_test.go Show popup message with breaking changes on startup 2024-03-12 13:27:14 +01:00
views.go Copy gocui files into lazygit repo under pkg/gocui 2026-04-30 14:29:08 +02:00