summaryrefslogtreecommitdiffstats
path: root/pkg/gui/files_panel.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2019-10-30 20:23:25 +1100
committerJesse Duffield <jessedduffield@gmail.com>2019-11-05 19:22:01 +1100
commit820f3d5cbb556f1c117906e4174f35ecf71e2ed5 (patch)
tree591c593fff6636707d06860cc7b918a92c573de0 /pkg/gui/files_panel.go
parent081598d98944cdb95bfa649812565127c0592f5e (diff)
support split view in staging panel and staging ranges
Diffstat (limited to 'pkg/gui/files_panel.go')
-rw-r--r--pkg/gui/files_panel.go27
1 files changed, 23 insertions, 4 deletions
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go
index 043c6ceab..76bfe93af 100644
--- a/pkg/gui/files_panel.go
+++ b/pkg/gui/files_panel.go
@@ -72,14 +72,33 @@ func (gui *Gui) handleFileSelect(g *gocui.Gui, v *gocui.View, alreadySelected bo
return gui.refreshMergePanel()
}
- content := gui.GitCommand.Diff(file, false)
+ content := gui.GitCommand.Diff(file, false, false)
+ contentCached := gui.GitCommand.Diff(file, false, true)
+ leftContent := content
+ if file.HasStagedChanges && file.HasUnstagedChanges {
+ gui.State.SplitMainPanel = true
+ } else {
+ gui.State.SplitMainPanel = false
+ if file.HasUnstagedChanges {
+ leftContent = content
+ } else {
+ leftContent = contentCached
+ }
+ }
+
if alreadySelected {
g.Update(func(*gocui.Gui) error {
- return gui.setViewContent(gui.g, gui.getMainView(), content)
+ if err := gui.setViewContent(gui.g, gui.getSecondaryView(), contentCached); err != nil {
+ return err
+ }
+ return gui.setViewContent(gui.g, gui.getMainView(), leftContent)
})
return nil
}
- return gui.renderString(g, "main", content)
+ if err := gui.renderString(g, "secondary", contentCached); err != nil {
+ return err
+ }
+ return gui.renderString(g, "main", leftContent)
}
func (gui *Gui) refreshFiles() error {
@@ -180,7 +199,7 @@ func (gui *Gui) handleEnterFile(g *gocui.Gui, v *gocui.View) error {
if file.HasInlineMergeConflicts {
return gui.handleSwitchToMerge(g, v)
}
- if !file.HasUnstagedChanges || file.HasMergeConflicts {
+ if file.HasMergeConflicts {
return gui.createErrorPanel(g, gui.Tr.SLocalize("FileStagingRequirements"))
}
if err := gui.changeContext("main", "staging"); err != nil {