summaryrefslogtreecommitdiffhomepage
path: root/debug-me.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2017-04-18 11:32:49 -0400
committerJoey Hess <joeyh@joeyh.name>2017-04-18 11:32:59 -0400
commit5e81ebbd1a6f8911acd537923f2f3c1df4971bbc (patch)
treedbfef37014fbe73930ddd4655ca3234337ca7c0a /debug-me.hs
parent5916c8406367b9033094359d6da2e079440d8f1c (diff)
downloaddebug-me-5e81ebbd1a6f8911acd537923f2f3c1df4971bbc.tar.gz
fix backlog truncation bug
That I was stuck on for hours yesterday, oops! This commit was sponsored by Bruno BEAUFILS on Patreon.
Diffstat (limited to 'debug-me.hs')
-rw-r--r--debug-me.hs15
1 files changed, 11 insertions, 4 deletions
diff --git a/debug-me.hs b/debug-me.hs
index 9332270..7a9f527 100644
--- a/debug-me.hs
+++ b/debug-me.hs
@@ -278,19 +278,26 @@ sendPtyInput ichan ochan p backlog logger = go
go
-- | Truncate the Backlog to remove entries older than the one
--- that the Activity refers to.
+-- that the Activity Entered refers to, but only if the referred
+-- to Activity is an Activity Seen.
--
--- If the activity refers to an item not in the backlog, no truncation is
+-- Once the developer has referred to a given Activity Seen in
+-- their Activity Entered, they cannot refer backwards to anything
+-- that came before it.
+--
+-- If the Activity refers to an item not in the backlog, no truncation is
-- done.
truncateBacklog :: Backlog -> Activity Entered -> Backlog
truncateBacklog (Backlog (b :| l)) (Activity _ hp _)
- | Just (activityLogHash b) == hp = Backlog (b :| [])
+ | truncationpoint b = Backlog (b :| [])
| otherwise = Backlog (b :| go [] l)
where
go c [] = reverse c
go c (x:xs)
- | Just (activityLogHash x) == hp = reverse (x:c)
+ | truncationpoint x = reverse (x:c)
| otherwise = go (x:c) xs
+ truncationpoint x@(ActivitySeen {}) = Just (activityLogHash x) == hp
+ truncationpoint _ = False
-- | Entered activity is legal when it points to the last Seen activvity,
-- because this guarantees that the person who entered it saw