Files
lazygit/pkg/integration/tests/main_view/select_diff_lines.go
Stefan HallerandGitHub Copilot aba33ad93b Name diff options after the view that now uses them
Hunk defaults and wrapping no longer belong to a staging panel. Rename both
public keys with automatic migration, and remove panel-era English strings so
config, UI, schema, and generated docs describe the surviving interface.

Co-Authored-By: GitHub Copilot <copilot@github.com>
2026-10-05 11:44:42 +02:00

55 lines
1.4 KiB
Go

package main_view
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var SelectDiffLines = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Focusing the main view selects the first visible change line, and the arrow keys move the selection",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {
config.GetUserConfig().Gui.UseHunkModeInDiffView = false
},
SetupRepo: func(shell *Shell) {
shell.CreateFileAndAdd("file1", "one\ntwo\nthree\nfour\nfive\n")
shell.Commit("one")
shell.UpdateFile("file1", "one\ntwo\nTHREE\nfour\nfive\n")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Files().
IsFocused().
Lines(
Contains("file1").IsSelected(),
).
Press(keys.Universal.FocusMainView)
// The selection starts on the first change line rather than at the top of the
// diff, so that it lands on something to act on without the view jumping.
t.Views().Main().
IsFocused().
SelectionIsActive().
SelectedLines(
Contains("-three"),
).
Press(keys.Universal.NextItem).
SelectedLines(
Contains("+THREE"),
).
Press(keys.Universal.PrevItem).
SelectedLines(
Contains("-three"),
).
Press(keys.Universal.GotoTop).
SelectedLines(
Contains("diff --git a/file1 b/file1"),
).
Press(keys.Universal.Return)
t.Views().Files().
IsFocused()
},
})