mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-31 14:24:25 +03:00
Always render diffs to the main/secondary context pair, even for files
Previously we would render the diff for a directory to the main/secondary pair, but a diff for a file to the staging/stagingSecondary pair. (And similar for commit files: main/secondary for directories, but patchBuilding/patchBuildingSecondary for files.) I always found this confusing and couldn't really understand why we are doing this; but now it gets in my way because I want to attach a controller to main/secondary so that they can be focused. So change it to always use the main context pair for everything we render from a side panel.
This commit is contained in:
@ -138,7 +138,7 @@ func (self *CommitFilesController) GetKeybindings(opts types.KeybindingsOpts) []
|
||||
func (self *CommitFilesController) GetMouseKeybindings(opts types.KeybindingsOpts) []*gocui.ViewMouseBinding {
|
||||
return []*gocui.ViewMouseBinding{
|
||||
{
|
||||
ViewName: "patchBuilding",
|
||||
ViewName: "main",
|
||||
Key: gocui.MouseLeft,
|
||||
Handler: self.onClickMain,
|
||||
FocusedView: self.context().GetViewName(),
|
||||
@ -163,13 +163,8 @@ func (self *CommitFilesController) GetOnRenderToMain() func() {
|
||||
cmdObj := self.c.Git().WorkingTree.ShowFileDiffCmdObj(from, to, reverse, node.GetPath(), false)
|
||||
task := types.NewRunPtyTask(cmdObj.GetCmd())
|
||||
|
||||
pair := self.c.MainViewPairs().Normal
|
||||
if node.File != nil {
|
||||
pair = self.c.MainViewPairs().PatchBuilding
|
||||
}
|
||||
|
||||
self.c.RenderToMainViews(types.RefreshMainOpts{
|
||||
Pair: pair,
|
||||
Pair: self.c.MainViewPairs().Normal,
|
||||
Main: &types.ViewUpdateOpts{
|
||||
Title: self.c.Tr.Patch,
|
||||
SubTitle: self.c.Helpers().Diff.IgnoringWhitespaceSubTitle(),
|
||||
|
@ -214,12 +214,6 @@ func (self *FilesController) GetMouseKeybindings(opts types.KeybindingsOpts) []*
|
||||
Handler: self.onClickMain,
|
||||
FocusedView: self.context().GetViewName(),
|
||||
},
|
||||
{
|
||||
ViewName: "patchBuilding",
|
||||
Key: gocui.MouseLeft,
|
||||
Handler: self.onClickMain,
|
||||
FocusedView: self.context().GetViewName(),
|
||||
},
|
||||
{
|
||||
ViewName: "mergeConflicts",
|
||||
Key: gocui.MouseLeft,
|
||||
@ -232,12 +226,6 @@ func (self *FilesController) GetMouseKeybindings(opts types.KeybindingsOpts) []*
|
||||
Handler: self.onClickSecondary,
|
||||
FocusedView: self.context().GetViewName(),
|
||||
},
|
||||
{
|
||||
ViewName: "patchBuildingSecondary",
|
||||
Key: gocui.MouseLeft,
|
||||
Handler: self.onClickSecondary,
|
||||
FocusedView: self.context().GetViewName(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -304,11 +292,6 @@ func (self *FilesController) GetOnRenderToMain() func() {
|
||||
|
||||
self.c.Helpers().MergeConflicts.ResetMergeState()
|
||||
|
||||
pair := self.c.MainViewPairs().Normal
|
||||
if node.File != nil {
|
||||
pair = self.c.MainViewPairs().Staging
|
||||
}
|
||||
|
||||
split := self.c.UserConfig().Gui.SplitDiff == "always" || (node.GetHasUnstagedChanges() && node.GetHasStagedChanges())
|
||||
mainShowsStaged := !split && node.GetHasStagedChanges()
|
||||
|
||||
@ -318,7 +301,7 @@ func (self *FilesController) GetOnRenderToMain() func() {
|
||||
title = self.c.Tr.StagedChanges
|
||||
}
|
||||
refreshOpts := types.RefreshMainOpts{
|
||||
Pair: pair,
|
||||
Pair: self.c.MainViewPairs().Normal,
|
||||
Main: &types.ViewUpdateOpts{
|
||||
Task: types.NewRunPtyTask(cmdObj.GetCmd()),
|
||||
SubTitle: self.c.Helpers().Diff.IgnoringWhitespaceSubTitle(),
|
||||
|
@ -48,7 +48,7 @@ var Apply = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
t.Views().Information().Content(Contains("Building patch"))
|
||||
|
||||
t.Views().PatchBuildingSecondary().Content(Contains("second line"))
|
||||
t.Views().Secondary().Content(Contains("second line"))
|
||||
|
||||
t.Common().SelectPatchOption(MatchesRegexp(`Apply patch$`))
|
||||
|
||||
|
@ -35,7 +35,7 @@ var ApplyInReverse = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
t.Views().Information().Content(Contains("Building patch"))
|
||||
|
||||
t.Views().PatchBuildingSecondary().Content(Contains("+file1 content"))
|
||||
t.Views().Secondary().Content(Contains("+file1 content"))
|
||||
|
||||
t.Common().SelectPatchOption(Contains("Apply patch in reverse"))
|
||||
|
||||
|
@ -44,13 +44,13 @@ var ApplyInReverseWithConflict = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Tap(func() {
|
||||
t.Views().Information().Content(Contains("Building patch"))
|
||||
|
||||
t.Views().PatchBuildingSecondary().Content(
|
||||
t.Views().Secondary().Content(
|
||||
Contains("+more file1 content"))
|
||||
}).
|
||||
SelectNextItem().
|
||||
PressPrimaryAction()
|
||||
|
||||
t.Views().PatchBuildingSecondary().Content(
|
||||
t.Views().Secondary().Content(
|
||||
Contains("+more file1 content").Contains("+more file2 content"))
|
||||
|
||||
t.Common().SelectPatchOption(Contains("Apply patch in reverse"))
|
||||
|
@ -43,8 +43,8 @@ var MoveRangeToIndex = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
t.Views().Information().Content(Contains("Building patch"))
|
||||
|
||||
t.Views().PatchBuildingSecondary().Content(Contains("second line"))
|
||||
t.Views().PatchBuildingSecondary().Content(Contains("file two content"))
|
||||
t.Views().Secondary().Content(Contains("second line"))
|
||||
t.Views().Secondary().Content(Contains("file two content"))
|
||||
|
||||
t.Common().SelectPatchOption(MatchesRegexp(`Move patch out into index$`))
|
||||
|
||||
|
@ -35,7 +35,7 @@ var MoveToIndex = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
t.Views().Information().Content(Contains("Building patch"))
|
||||
|
||||
t.Views().PatchBuildingSecondary().Content(Contains("+file1 content"))
|
||||
t.Views().Secondary().Content(Contains("+file1 content"))
|
||||
|
||||
t.Common().SelectPatchOption(Contains("Move patch out into index"))
|
||||
|
||||
|
@ -53,7 +53,7 @@ var MoveToIndexPartial = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Tap(func() {
|
||||
t.Views().Information().Content(Contains("Building patch"))
|
||||
|
||||
t.Views().PatchBuildingSecondary().
|
||||
t.Views().Secondary().
|
||||
ContainsLines(
|
||||
Contains(`-first line`),
|
||||
Contains(`+first line2`),
|
||||
|
@ -33,7 +33,7 @@ var MoveToIndexWorksEvenIfNoprefixIsSet = NewIntegrationTest(NewIntegrationTestA
|
||||
).
|
||||
PressPrimaryAction()
|
||||
|
||||
t.Views().PatchBuildingSecondary().Content(Contains("+file1 content"))
|
||||
t.Views().Secondary().Content(Contains("+file1 content"))
|
||||
|
||||
t.Common().SelectPatchOption(Contains("Move patch out into index"))
|
||||
|
||||
|
@ -35,7 +35,7 @@ var RemoveFromCommit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
t.Views().Information().Content(Contains("Building patch"))
|
||||
|
||||
t.Views().PatchBuildingSecondary().Content(Contains("+file1 content"))
|
||||
t.Views().Secondary().Content(Contains("+file1 content"))
|
||||
|
||||
t.Common().SelectPatchOption(Contains("Remove patch from original commit"))
|
||||
|
||||
|
@ -58,11 +58,12 @@ var StashStagedPartialFile = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
)
|
||||
|
||||
t.Views().Files().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("file-staged"),
|
||||
)
|
||||
|
||||
t.Views().Staging().
|
||||
t.Views().Main().
|
||||
Content(
|
||||
Contains(" line1\n line2\n line3\n-line4\n+line4 mod"),
|
||||
)
|
||||
|
Reference in New Issue
Block a user