Skip to content

Commit 2445f66

Browse files
committed
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.
1 parent d0957b8 commit 2445f66

11 files changed

+15
-36
lines changed

pkg/gui/controllers/commits_files_controller.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func (self *CommitFilesController) GetKeybindings(opts types.KeybindingsOpts) []
138138
func (self *CommitFilesController) GetMouseKeybindings(opts types.KeybindingsOpts) []*gocui.ViewMouseBinding {
139139
return []*gocui.ViewMouseBinding{
140140
{
141-
ViewName: "patchBuilding",
141+
ViewName: "main",
142142
Key: gocui.MouseLeft,
143143
Handler: self.onClickMain,
144144
FocusedView: self.context().GetViewName(),
@@ -163,13 +163,8 @@ func (self *CommitFilesController) GetOnRenderToMain() func() {
163163
cmdObj := self.c.Git().WorkingTree.ShowFileDiffCmdObj(from, to, reverse, node.GetPath(), false)
164164
task := types.NewRunPtyTask(cmdObj.GetCmd())
165165

166-
pair := self.c.MainViewPairs().Normal
167-
if node.File != nil {
168-
pair = self.c.MainViewPairs().PatchBuilding
169-
}
170-
171166
self.c.RenderToMainViews(types.RefreshMainOpts{
172-
Pair: pair,
167+
Pair: self.c.MainViewPairs().Normal,
173168
Main: &types.ViewUpdateOpts{
174169
Title: self.c.Tr.Patch,
175170
SubTitle: self.c.Helpers().Diff.IgnoringWhitespaceSubTitle(),

pkg/gui/controllers/files_controller.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,6 @@ func (self *FilesController) GetMouseKeybindings(opts types.KeybindingsOpts) []*
213213
Handler: self.onClickMain,
214214
FocusedView: self.context().GetViewName(),
215215
},
216-
{
217-
ViewName: "patchBuilding",
218-
Key: gocui.MouseLeft,
219-
Handler: self.onClickMain,
220-
FocusedView: self.context().GetViewName(),
221-
},
222216
{
223217
ViewName: "mergeConflicts",
224218
Key: gocui.MouseLeft,
@@ -231,12 +225,6 @@ func (self *FilesController) GetMouseKeybindings(opts types.KeybindingsOpts) []*
231225
Handler: self.onClickSecondary,
232226
FocusedView: self.context().GetViewName(),
233227
},
234-
{
235-
ViewName: "patchBuildingSecondary",
236-
Key: gocui.MouseLeft,
237-
Handler: self.onClickSecondary,
238-
FocusedView: self.context().GetViewName(),
239-
},
240228
}
241229
}
242230

@@ -271,11 +259,6 @@ func (self *FilesController) GetOnRenderToMain() func() {
271259

272260
self.c.Helpers().MergeConflicts.ResetMergeState()
273261

274-
pair := self.c.MainViewPairs().Normal
275-
if node.File != nil {
276-
pair = self.c.MainViewPairs().Staging
277-
}
278-
279262
split := self.c.UserConfig().Gui.SplitDiff == "always" || (node.GetHasUnstagedChanges() && node.GetHasStagedChanges())
280263
mainShowsStaged := !split && node.GetHasStagedChanges()
281264

@@ -285,7 +268,7 @@ func (self *FilesController) GetOnRenderToMain() func() {
285268
title = self.c.Tr.StagedChanges
286269
}
287270
refreshOpts := types.RefreshMainOpts{
288-
Pair: pair,
271+
Pair: self.c.MainViewPairs().Normal,
289272
Main: &types.ViewUpdateOpts{
290273
Task: types.NewRunPtyTask(cmdObj.GetCmd()),
291274
SubTitle: self.c.Helpers().Diff.IgnoringWhitespaceSubTitle(),

pkg/integration/tests/patch_building/apply.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var Apply = NewIntegrationTest(NewIntegrationTestArgs{
4848

4949
t.Views().Information().Content(Contains("Building patch"))
5050

51-
t.Views().PatchBuildingSecondary().Content(Contains("second line"))
51+
t.Views().Secondary().Content(Contains("second line"))
5252

5353
t.Common().SelectPatchOption(MatchesRegexp(`Apply patch$`))
5454

pkg/integration/tests/patch_building/apply_in_reverse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var ApplyInReverse = NewIntegrationTest(NewIntegrationTestArgs{
3535

3636
t.Views().Information().Content(Contains("Building patch"))
3737

38-
t.Views().PatchBuildingSecondary().Content(Contains("+file1 content"))
38+
t.Views().Secondary().Content(Contains("+file1 content"))
3939

4040
t.Common().SelectPatchOption(Contains("Apply patch in reverse"))
4141

pkg/integration/tests/patch_building/apply_in_reverse_with_conflict.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ var ApplyInReverseWithConflict = NewIntegrationTest(NewIntegrationTestArgs{
4444
Tap(func() {
4545
t.Views().Information().Content(Contains("Building patch"))
4646

47-
t.Views().PatchBuildingSecondary().Content(
47+
t.Views().Secondary().Content(
4848
Contains("+more file1 content"))
4949
}).
5050
SelectNextItem().
5151
PressPrimaryAction()
5252

53-
t.Views().PatchBuildingSecondary().Content(
53+
t.Views().Secondary().Content(
5454
Contains("+more file1 content").Contains("+more file2 content"))
5555

5656
t.Common().SelectPatchOption(Contains("Apply patch in reverse"))

pkg/integration/tests/patch_building/move_range_to_index.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ var MoveRangeToIndex = NewIntegrationTest(NewIntegrationTestArgs{
4343

4444
t.Views().Information().Content(Contains("Building patch"))
4545

46-
t.Views().PatchBuildingSecondary().Content(Contains("second line"))
47-
t.Views().PatchBuildingSecondary().Content(Contains("file two content"))
46+
t.Views().Secondary().Content(Contains("second line"))
47+
t.Views().Secondary().Content(Contains("file two content"))
4848

4949
t.Common().SelectPatchOption(MatchesRegexp(`Move patch out into index$`))
5050

pkg/integration/tests/patch_building/move_to_index.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var MoveToIndex = NewIntegrationTest(NewIntegrationTestArgs{
3535

3636
t.Views().Information().Content(Contains("Building patch"))
3737

38-
t.Views().PatchBuildingSecondary().Content(Contains("+file1 content"))
38+
t.Views().Secondary().Content(Contains("+file1 content"))
3939

4040
t.Common().SelectPatchOption(Contains("Move patch out into index"))
4141

pkg/integration/tests/patch_building/move_to_index_partial.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ var MoveToIndexPartial = NewIntegrationTest(NewIntegrationTestArgs{
5353
Tap(func() {
5454
t.Views().Information().Content(Contains("Building patch"))
5555

56-
t.Views().PatchBuildingSecondary().
56+
t.Views().Secondary().
5757
ContainsLines(
5858
Contains(`-first line`),
5959
Contains(`+first line2`),

pkg/integration/tests/patch_building/move_to_index_works_even_if_noprefix_is_set.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var MoveToIndexWorksEvenIfNoprefixIsSet = NewIntegrationTest(NewIntegrationTestA
3333
).
3434
PressPrimaryAction()
3535

36-
t.Views().PatchBuildingSecondary().Content(Contains("+file1 content"))
36+
t.Views().Secondary().Content(Contains("+file1 content"))
3737

3838
t.Common().SelectPatchOption(Contains("Move patch out into index"))
3939

pkg/integration/tests/patch_building/remove_from_commit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var RemoveFromCommit = NewIntegrationTest(NewIntegrationTestArgs{
3535

3636
t.Views().Information().Content(Contains("Building patch"))
3737

38-
t.Views().PatchBuildingSecondary().Content(Contains("+file1 content"))
38+
t.Views().Secondary().Content(Contains("+file1 content"))
3939

4040
t.Common().SelectPatchOption(Contains("Remove patch from original commit"))
4141

0 commit comments

Comments
 (0)