Advertise the metadata protocol to git as well, not only to a pager

A rawGit diff renderer needs no pty -- git renders the diff itself, and
only a pager needs a terminal to be spawned at all -- so newPtyTask hands
that case straight to newCmdTask. But the OSC1717 advertisement was set
forty lines further down, past that early return, so git was never asked
to annotate its output and the word-diff renderer we just started
trusting emitted no records.

Set it before the branch, next to LAZYGIT_COLUMNS, which is there for the
same reason. Nothing else changes: a renderer that doesn't know the
variable ignores it, and git says nothing for the formats it doesn't
annotate, which is every format a rawGit renderer without word-diff
arguments produces.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Stefan Haller 2026-08-05 18:48:41 +02:00
parent 473f83ec49
commit 07ec8a72b6

View file

@ -65,6 +65,15 @@ func (gui *Gui) newPtyTask(view *gocui.View, cmd *exec.Cmd, prefix string) error
// Set LAZYGIT_COLUMNS for diff renderer scripts that can't query the terminal width directly.
cmd.Env = append(cmd.Env, fmt.Sprintf("LAZYGIT_COLUMNS=%d", width))
// Advertise the diff-line metadata protocol versions we understand, so that
// whatever renders the diff annotates each line with an OSC sequence we can read
// back (see diff-line-metadata-notes.md). Set before the no-pty path below,
// because git renders the diff itself there and is one of the things that speaks
// the protocol — for its word-diff formats, whose inline markup we could not
// otherwise resolve. Anything that doesn't understand the variable ignores it, so
// this is safe to set unconditionally.
cmd.Env = append(cmd.Env, "OSC1717=V1")
if gui.stateAccessor.GetDiffRendererConfigManager().GetDiffRendererType() == config.DiffRendererType_RawGit {
// If we're not using a custom diff renderer, then we don't need to use a pty
return gui.newCmdTask(view, cmd, prefix)
@ -100,13 +109,6 @@ func (gui *Gui) newPtyTask(view *gocui.View, cmd *exec.Cmd, prefix string) error
cmd.Env = append(cmd.Env, "GIT_PAGER="+pager)
// Advertise to a metadata-aware pager (e.g. a patched delta) the diff-line
// metadata protocol versions we understand, so it annotates each line with
// an OSC sequence we can read back (see diff-line-metadata-notes.md). A
// pager that doesn't understand it ignores the variable, so this is safe to
// set unconditionally.
cmd.Env = append(cmd.Env, "OSC1717=V1")
manager := gui.getManager(view)
// Size the pty from the view's dimensions here, on the UI thread; the