jesseduffield.lazygit/pkg/gui/presentation
Stefan Haller da4dfa17d5 Render the custom-patch secondary pane through the pager, via a real git diff
The secondary pane showed the custom patch with a bespoke in-memory render
(PatchBuilder.RenderAggregatedPatch / FormatView). That had two problems: it
could never be fed to a pager the way the main view's diff is (a stdin pager
might have worked, but an external diff tool like difftastic, which diffs two
files rather than a unified diff, could not), and its hand-rolled hunk/context
handling differed subtly from git's.

Materialize the patch instead as two real file trees under a temp dir — a/ holds
each patched file's "from"-side content, b/ that content with the patch applied —
and render it with `git diff --no-index`, reusing the exact pager wiring the main
view uses (stdin pager, external diff, or git's own colour as the raw fallback).
`--no-index` honors both GIT_PAGER and --ext-diff, so every pager type now renders
the custom patch like any other diff, and git computes the context, fixing the
quirks. Because the secondary is now an async diff task, the post-removal
selection reveal (which rides a task's restore) finally takes effect.

The trees are named a/b so that with --no-prefix the diff shows the real
repo-relative paths; added files are seeded empty in a/ so they pair up and show
their real paths rather than git's directory-comparison "added in b" form. The
patch builder owns the temp dir's lifetime (created on Start, removed on Reset)
and bumps a generation counter on every change, so the trees are rebuilt only
when the patch actually changes — covering the focused-main view and the old
explorer alike, without rebuilding on mere navigation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-08 12:59:00 +02:00
..
authors Replace go-runewidth with uniseg 2025-12-23 16:49:16 +01:00
graph Use more widely-supported Unicode symbols for the commit graph 2026-05-04 13:06:29 +02:00
icons Show PR icons in branches list 2026-04-01 09:13:55 +02:00
branches.go Show a Github PR's combined checks state in branches list and main view 2026-08-02 13:06:21 +02:00
branches_test.go Show a Github PR's combined checks state in branches list and main view 2026-08-02 13:06:21 +02:00
commits.go Show -C for fixup todos in rebase if present 2026-01-28 10:15:48 +01:00
commits_test.go Use more widely-supported Unicode symbols for the commit graph 2026-05-04 13:06:29 +02:00
files.go Show renamed files in the custom patch builder 2026-07-04 13:05:09 +02:00
files_test.go Render the custom-patch secondary pane through the pager, via a real git diff 2026-08-08 12:59:00 +02:00
item_operations.go Show inline waiting status when checking out a local branch 2024-03-17 07:53:38 +01:00
loader.go Move Loader to presentation package 2025-05-06 09:52:53 +02:00
reflog_commits.go Make Commit.Hash a getter for an unexported hash field 2025-04-29 14:57:15 +02:00
remote_branches.go Standardise on using lo for slice functions 2023-07-30 18:51:23 +10:00
remotes.go Move Loader to presentation package 2025-05-06 09:52:53 +02:00
stash_entries.go feat: add age on stash lines 2023-12-27 11:21:49 +01:00
status.go Make WorkingTreeState a struct, and add cherry-picking and reverting states 2025-04-20 15:53:17 +02:00
submodules.go refactor: use strings.Builder and strings.Repeat to simplify code 2025-12-03 18:34:21 +01:00
suggestions.go Standardise on using lo for slice functions 2023-07-30 18:51:23 +10:00
tags.go Move Loader to presentation package 2025-05-06 09:52:53 +02:00
worktrees.go Show branch name and detached HEAD in worktrees tab 2026-03-08 12:51:46 +01:00
worktrees_test.go Show branch name and detached HEAD in worktrees tab 2026-03-08 12:51:46 +01:00