Skip to content

Commit

Permalink
feat: let the staging secondary panel change view mode
Browse files Browse the repository at this point in the history
  • Loading branch information
AzraelSec committed Jun 5, 2024
1 parent 8bb5e7b commit f891f11
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/gui/controllers/helpers/window_arrangement_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,15 @@ func mainSectionChildren(args WindowArrangementArgs) []*boxlayout.Box {
}
}

if args.CurrentWindow == "secondary" && args.ScreenMode == types.SCREEN_FULL {
return []*boxlayout.Box{
{
Window: "secondary",
Weight: 1,
},
}
}

return []*boxlayout.Box{
{
Window: "main",
Expand All @@ -239,7 +248,7 @@ func getMidSectionWeights(args WindowArrangementArgs) (int, int) {
mainSectionWeight = 5 // need to shrink side panel to make way for main panels if side-by-side
}

if args.CurrentWindow == "main" {
if args.CurrentWindow == "main" || args.CurrentWindow == "secondary" {
if args.ScreenMode == types.SCREEN_HALF || args.ScreenMode == types.SCREEN_FULL {
sideSectionWeight = 0
}
Expand Down
47 changes: 47 additions & 0 deletions pkg/integration/tests/staging/diff_change_screen_mode.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package staging

import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)

var DiffChangeScreenMode = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Change the staged changes screen mode",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.CreateFile("file", "first line\nsecond line")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Files().
Focus().
PressEnter()

t.Views().Staging().
IsFocused().
PressPrimaryAction().
Title(Equals("Unstaged changes")).
Content(Contains("+second line").DoesNotContain("+first line")).
PressTab()

t.Views().StagingSecondary().
IsFocused().
Title(Equals("Staged changes")).
Content(Contains("+first line").DoesNotContain("+second line")).
Press(keys.Universal.NextScreenMode).
Tap(func() {
t.Views().AppStatus().
IsInvisible()
t.Views().Staging().
IsVisible()
}).
Press(keys.Universal.NextScreenMode).
Tap(func() {
t.Views().AppStatus().
IsInvisible()
t.Views().Staging().
IsInvisible()
})
},
})
1 change: 1 addition & 0 deletions pkg/integration/tests/test_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ var tests = []*components.IntegrationTest{
reflog.DoNotShowBranchMarkersInReflogSubcommits,
reflog.Patch,
reflog.Reset,
staging.DiffChangeScreenMode,
staging.DiffContextChange,
staging.DiscardAllChanges,
staging.Search,
Expand Down

0 comments on commit f891f11

Please sign in to comment.