summaryrefslogtreecommitdiffstats
path: root/pkg/gui/gui.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-03-21 11:56:34 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-03-25 09:39:04 +1100
commitf80d15062b4296c452645b167e76c1a5a13e52fc (patch)
tree7b3d14c768c69e6a4095483c9d9679dc2f4103bc /pkg/gui/gui.go
parentb1b0219f04ab0e17dd0ce0f5469dee7daecf2717 (diff)
use reflog undo history pointer
Diffstat (limited to 'pkg/gui/gui.go')
-rw-r--r--pkg/gui/gui.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index 1ae9199eb..fd4e6bfd4 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -214,6 +214,21 @@ type guiState struct {
PrevMainWidth int
PrevMainHeight int
OldInformation string
+
+ Undo UndoState
+}
+
+// we facilitate 'undo' actions via parsing the reflog and doing the reverse
+// of the most recent entry. In order to to multiple undo's in a row we need to
+// keep track of where we are in the reflog. We do that via a key which is the
+// concatenation of the reflog's timestamp and message.
+// We also store the index of that reflog entry so that if we end up with a
+// different entry at that index we know the user must have done something
+// themselves (e.g. checked out a branch) to cause new reflog entries to be created
+// meaning we can reset the undo state.
+type UndoState struct {
+ ReflogKey string
+ ReflogIdx int
}
// for now the split view will always be on