jesseduffield.lazygit/docs-master
Stefan Haller 4b57cc9efe Select and stage ranges and hunks from the focused main view
Step 1 made the focused main view a staging surface for a single line. This
adds the range and hunk selection the staging view has, so you can stage (or
unstage) a range or a whole hunk in place — `v` starts a range, shift-up/down
extend one, `a` toggles hunk selection — without diving into the staging view.

The selection mode (line / range / hunk, plus sticky-range and "the user turned
hunk mode on themselves") lives on MainContext rather than the controller,
because three places need a pane's mode: the main view controller that drives
it, the focus controller that resets it when you focus the view, and togglePanel
which sets it on the *other* pane. The selected line and the range anchor stay
in the gocui view itself (its cursor and rangeSelectStartY), so the existing
native range-select rendering draws the highlight — no new highlight machinery.
Hunk bounds come from the diff-line metadata (the isChange run around the
cursor, via ChangeBlockBounds), not from a parsed patch, so they work over any
conforming rendering. The up/down keys are mode-aware: hunk mode steps hunk to
hunk, a non-sticky range collapses on a plain move, a sticky range extends.

GetOnStageFocusedMainView now takes the selected view-line range instead of one
line; the files handler collects the change lines in the range and applies a
single patch. It identifies each change line's patch line by scanning the parsed
patch and matching (file line number, deletion?) identities, rather than looking
each number up with PatchLineForLineNumber. That lookup can't tell an addition at
the very start of a hunk from the deletion above it, nor an addition from the
deletion it replaces on a modified line — both of which a range routinely spans.
As a side effect this also fixes staging a change on the first line of a file.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-08 12:58:59 +02:00
..
dev Make copies of the docs and schema folders 2025-11-12 08:44:56 +01:00
keybindings Select and stage ranges and hunks from the focused main view 2026-08-08 12:58:59 +02:00
Config.md Replace gui.showSelectionInFocusedMainView config with on-demand selection 2026-08-08 12:58:59 +02:00
Custom_Command_Keybindings.md Convert keybinding fields to Keybinding 2026-05-25 15:32:47 +02:00
Custom_DiffRenderers.md Adapt documentation 2026-07-31 08:42:51 +02:00
Fixup_Commits.md Make copies of the docs and schema folders 2025-11-12 08:44:56 +01:00
Range_Select.md Make copies of the docs and schema folders 2025-11-12 08:44:56 +01:00
README.md Adapt documentation 2026-07-31 08:42:51 +02:00
Searching.md Make copies of the docs and schema folders 2025-11-12 08:44:56 +01:00
Stacked_Branches.md Make copies of the docs and schema folders 2025-11-12 08:44:56 +01:00
Undoing.md Fix undo shortcut in Undoing.md 2026-05-26 09:45:41 +02:00