1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-23 12:18:51 +02:00

Fix secondary window resize (#3637)

- **PR Description**
This PR fixes the behavior the staging secondary panel (staged lines)
currently has in relation to changing its view mode. In particular,
these changes allows the users to expand the secondary panels the same
way all the others do.

This closes #3629.

- **Please check if the PR fulfills these requirements**

* [x] Cheatsheets are up-to-date (run `go generate ./...`)
* [x] Code has been formatted (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting))
* [x] Tests have been added/updated (see
[here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md)
for the integration test guide)
* [ ] Text is internationalised (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation))
* [ ] Docs have been updated if necessary
* [x] You've read through your own file changes for silly mistakes etc
This commit is contained in:
Stefan Haller 2024-06-07 22:54:25 +02:00 committed by GitHub
commit 92f13fc56e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 59 additions and 2 deletions

View File

@ -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{ return []*boxlayout.Box{
{ {
Window: "main", Window: "main",
@ -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 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 { if args.ScreenMode == types.SCREEN_HALF || args.ScreenMode == types.SCREEN_FULL {
sideSectionWeight = 0 sideSectionWeight = 0
} }

View File

@ -565,7 +565,7 @@ func (self *ViewDriver) IsVisible() *ViewDriver {
func (self *ViewDriver) IsInvisible() *ViewDriver { func (self *ViewDriver) IsInvisible() *ViewDriver {
self.t.assertWithRetries(func() (bool, string) { self.t.assertWithRetries(func() (bool, string) {
return !self.getView().Visible, fmt.Sprintf("%s: Expected view to be visible, but it was not", self.context) return !self.getView().Visible, fmt.Sprintf("%s: Expected view to be invisible, but it was not", self.context)
}) })
return self return self

View File

@ -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()
})
},
})

View File

@ -245,6 +245,7 @@ var tests = []*components.IntegrationTest{
reflog.DoNotShowBranchMarkersInReflogSubcommits, reflog.DoNotShowBranchMarkersInReflogSubcommits,
reflog.Patch, reflog.Patch,
reflog.Reset, reflog.Reset,
staging.DiffChangeScreenMode,
staging.DiffContextChange, staging.DiffContextChange,
staging.DiscardAllChanges, staging.DiscardAllChanges,
staging.Search, staging.Search,