Always set LAZYGIT_COLUMNS

The env var was previously set only on Windows, where the no-op pty
stub was just running the command without a pty and needed to expose
the width to pager scripts another way. With ConPTY coming to Windows
the rationale disappears there, but the env var is documented in
docs/Custom_Pagers.md for pager scripts that can't query the terminal
width directly. Set it on every platform so those scripts remain
portable, regardless of whether a pty is in play.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Stefan Haller 2026-06-30 09:45:26 +02:00
parent 3c04b30336
commit 51c8f9e6ad

View file

@ -3,6 +3,7 @@
package gui
import (
"fmt"
"io"
"os"
"os/exec"
@ -45,6 +46,12 @@ func (gui *Gui) onResize() error {
// command.
func (gui *Gui) newPtyTask(view *gocui.View, cmd *exec.Cmd, prefix string) error {
width := view.InnerWidth()
// LAZYGIT_COLUMNS is documented in docs/Custom_Pagers.md for pager
// scripts that can't query the terminal width directly. We set it on
// every platform so those scripts remain portable.
cmd.Env = append(cmd.Env, fmt.Sprintf("LAZYGIT_COLUMNS=%d", width))
pager := gui.stateAccessor.GetPagerConfig().GetPagerCommand(width)
externalDiffCommand := gui.stateAccessor.GetPagerConfig().GetExternalDiffCommand()
useExtDiffGitConfig := gui.stateAccessor.GetPagerConfig().GetUseExternalDiffGitConfig()