summaryrefslogtreecommitdiffstats
path: root/pkg/gui/diffing.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-08-22 13:03:20 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-08-23 14:29:18 +1000
commite290710f6741c046ee7e52e622af813e8955639b (patch)
tree65a0ea8e98d43c5119ac0ec902572e452fae7ee5 /pkg/gui/diffing.go
parent438abd6003aff9621f93b8531aa20baad2c8933c (diff)
support drilling down into the files of a diff
Diffstat (limited to 'pkg/gui/diffing.go')
-rw-r--r--pkg/gui/diffing.go27
1 files changed, 24 insertions, 3 deletions
diff --git a/pkg/gui/diffing.go b/pkg/gui/diffing.go
index 968887b30..b334fe768 100644
--- a/pkg/gui/diffing.go
+++ b/pkg/gui/diffing.go
@@ -40,9 +40,10 @@ func (gui *Gui) currentDiffTerminals() []string {
switch gui.currentContextKey() {
case "":
return nil
- case FILES_CONTEXT_KEY, COMMIT_FILES_CONTEXT_KEY:
- // not supporting these for now because I'm not sure how it would actually work
- return nil
+ case FILES_CONTEXT_KEY:
+ return []string{""}
+ case COMMIT_FILES_CONTEXT_KEY:
+ return []string{gui.State.Panels.CommitFiles.refName}
case LOCAL_BRANCHES_CONTEXT_KEY:
// for our local branches we want to include both the branch and its upstream
branch := gui.getSelectedBranch()
@@ -75,6 +76,19 @@ func (gui *Gui) currentDiffTerminal() string {
return names[0]
}
+func (gui *Gui) currentlySelectedFilename() string {
+ switch gui.currentContextKey() {
+ case FILES_CONTEXT_KEY, COMMIT_FILES_CONTEXT_KEY:
+ item := gui.getSideContextSelectedItem()
+ if item == nil {
+ return ""
+ }
+ return item.ID()
+ default:
+ return ""
+ }
+}
+
func (gui *Gui) diffStr() string {
output := gui.State.Modes.Diffing.Ref
@@ -82,9 +96,16 @@ func (gui *Gui) diffStr() string {
if right != "" {
output += " " + right
}
+
if gui.State.Modes.Diffing.Reverse {
output += " -R"
}
+
+ file := gui.currentlySelectedFilename()
+ if file != "" {
+ output += " -- " + file
+ }
+
return output
}