mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-10-05 21:46:49 -04:00
A renderer that speaks the protocol emits nothing unless it is asked to, so that its output stays plain wherever it is used outside lazygit. The variable names the versions we understand. git is one of the renderers we ask. It has no pager to spawn, and so no terminal to spawn one in, but it still renders the diff itself — for the word-diff formats, whose markup nothing else could resolve — so the request has to be made before we decide a pty isn't needed. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
51 lines
1.7 KiB
Go
51 lines
1.7 KiB
Go
package diff
|
|
|
|
import (
|
|
"github.com/jesseduffield/lazygit/pkg/config"
|
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
|
)
|
|
|
|
var DiffRendererMetadata = NewIntegrationTest(NewIntegrationTestArgs{
|
|
Description: "A diff renderer is told that we understand the OSC 1717 metadata protocol, and the records it emits don't show up in the rendered diff",
|
|
ExtraCmdArgs: []string{},
|
|
Skip: false,
|
|
SetupConfig: func(cfg *config.AppConfig) {
|
|
// A fake conforming renderer: it announces the protocol with a
|
|
// version-only record, reports the protocol versions it was offered, and
|
|
// then passes the diff through with a per-line record in front of every
|
|
// line.
|
|
cfg.GetUserConfig().Git.DiffRenderers = []config.DiffRendererConfig{
|
|
{Command: `printf '\033]1717;1\007'; ` +
|
|
`printf 'OFFERED:%s\n' "$OSC1717"; ` +
|
|
`while IFS= read -r line; do printf '\033]1717;1;c;1;;file1\007%s\n' "$line"; done`},
|
|
}
|
|
},
|
|
SetupRepo: func(shell *Shell) {
|
|
shell.CreateFileAndAdd("file1", "one\ntwo\n")
|
|
shell.Commit("one")
|
|
},
|
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
|
t.Views().Commits().
|
|
Focus().
|
|
Lines(
|
|
Contains("one").IsSelected(),
|
|
)
|
|
|
|
t.Views().Main().
|
|
// The renderer was offered the protocol version we understand.
|
|
Content(Contains("OFFERED:V1")).
|
|
// Its records are escape sequences, so none of them reaches the
|
|
// screen; the diff reads exactly as the renderer wrote it.
|
|
ContainsLines(
|
|
Equals("diff --git a/file1 b/file1"),
|
|
Contains("new file mode"),
|
|
Contains("index "),
|
|
Equals("--- /dev/null"),
|
|
Equals("+++ b/file1"),
|
|
Equals("@@ -0,0 +1,2 @@"),
|
|
Equals("+one"),
|
|
Equals("+two"),
|
|
)
|
|
},
|
|
})
|