mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-10-06 14:06:32 -04:00
Add a test for a main pane coming back after being emptied
A pane the render has nothing to show is emptied, but keeps the scroll position it was left at and its claim to the render it was showing. So when it comes back — the file it was showing before is selected again — its content is rendered under the same command it already had, which is taken for the content the view is showing, and the user is left partway down a diff they have only just been given. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
8f25e160e8
commit
ce6b293107
@@ -0,0 +1,64 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var PaneShownAgainStartsAtTheTop = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "A pane that was emptied while it wasn't shown starts at the top when it comes back, rather than where it was left",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
Width: 120,
|
||||
Height: 30,
|
||||
SetupConfig: func(cfg *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
lines := make([]string, 40)
|
||||
for i := range lines {
|
||||
lines[i] = fmt.Sprintf("line%02d", i+1)
|
||||
}
|
||||
shell.CreateFileAndAdd("file1", strings.Join(lines, "\n")+"\n")
|
||||
shell.CreateFileAndAdd("file2", "one\n")
|
||||
shell.Commit("one")
|
||||
|
||||
// More staged changes in file1 than fit in the pane they are shown in, so that
|
||||
// there is a position in it to lose, plus an unstaged change to give the file a
|
||||
// second pane.
|
||||
for i := range lines {
|
||||
lines[i] = strings.ToUpper(lines[i])
|
||||
}
|
||||
shell.UpdateFileAndAdd("file1", strings.Join(lines, "\n")+"\n")
|
||||
shell.UpdateFile("file1", strings.Join(lines, "\n")+"unstaged\n")
|
||||
|
||||
shell.UpdateFile("file2", "two\n")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Files().
|
||||
IsFocused().
|
||||
NavigateToLine(Contains("file1"))
|
||||
|
||||
t.Views().Secondary().
|
||||
IsVisible().
|
||||
Title(Equals("Staged changes")).
|
||||
ScrollWheelDown().
|
||||
ScrollWheelDown().
|
||||
OriginYAtLeast(1)
|
||||
|
||||
// A file with nothing staged leaves that pane with nothing to show, so it goes
|
||||
// away and is emptied.
|
||||
t.Views().Files().NavigateToLine(Contains("file2"))
|
||||
t.Views().Secondary().IsInvisible()
|
||||
|
||||
t.Views().Files().NavigateToLine(Contains("file1"))
|
||||
t.Views().Secondary().
|
||||
IsVisible().
|
||||
Content(Contains("+LINE40")).
|
||||
/* EXPECTED:
|
||||
OriginY(0)
|
||||
ACTUAL: */
|
||||
OriginYAtLeast(1)
|
||||
},
|
||||
})
|
||||
@@ -253,6 +253,7 @@ var tests = []*components.IntegrationTest{
|
||||
file.ExcludeWithoutInfoDir,
|
||||
file.Gitignore,
|
||||
file.GitignoreSpecialCharacters,
|
||||
file.PaneShownAgainStartsAtTheTop,
|
||||
file.RememberCommitMessageAfterFail,
|
||||
file.RenameSimilarityThresholdChange,
|
||||
file.RenamedFiles,
|
||||
|
||||
Reference in New Issue
Block a user