mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
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> |
||
|---|---|---|
| .. | ||
| dev | ||
| keybindings | ||
| Config.md | ||
| Custom_Command_Keybindings.md | ||
| Custom_DiffRenderers.md | ||
| Fixup_Commits.md | ||
| Range_Select.md | ||
| README.md | ||
| Searching.md | ||
| Stacked_Branches.md | ||
| Undoing.md | ||