helic 0.5.2.0 → 0.5.3.0
raw patch · 5 files changed
+13/−9 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- changelog.md +3/−1
- helic.cabal +1/−1
- lib/Helic/Interpreter/History.hs +6/−5
- test/Helic/Test/InsertEventTest.hs +2/−1
- test/Helic/Test/LoadTest.hs +1/−1
changelog.md view
@@ -1,4 +1,6 @@-# Unreleased+# 0.5.3.0++* Prevent events with timestamps older than the current history head from getting added to the history. # 0.5.1.0
helic.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: helic-version: 0.5.2.0+version: 0.5.3.0 synopsis: Clipboard Manager description: See <https://hackage.haskell.org/package/helic/docs/Helic.html> category: Clipboard
lib/Helic/Interpreter/History.hs view
@@ -67,17 +67,18 @@ sanitize e@Event {content} = e { content = sanitizeNewlines content } --- |Append an event to the history unless the newest event contains the same text or there was an event within the last--- second that contained the same text, to avoid clobbering due to cycles induced by external programs.+-- |Append an event to the history unless the latest event contains the same text, or there was an event within the last+-- second that contained the same text, or the new event has an earlier time stamp than the latest event, to avoid+-- clobbering due to cycles induced by external programs. appendIfValid :: Chronos.Time -> Event -> Seq Event -> Maybe (Seq Event)-appendIfValid now (sanitize -> e@Event {content}) = \case+appendIfValid now (sanitize -> e@Event {content, time}) = \case Seq.Empty -> Just (Seq.singleton e)- _ :|> Event _ _ _ newest | newest == content ->+ _ :|> Event _ _ latestTime latest | latest == content || time < latestTime -> Nothing hist | inRecent now e hist -> Nothing@@ -143,7 +144,7 @@ now <- Time.now atomicState' \ s -> do let rindex = length s - index - 1- case (s !? rindex) of+ case s !? rindex of Just event -> (Seq.deleteAt rindex s |> event { time = now }, Just event) Nothing ->
test/Helic/Test/InsertEventTest.hs view
@@ -7,7 +7,7 @@ import Polysemy.Chronos (interpretTimeChronosConstant) import Polysemy.Test (UnitTest, assertJust, runTestAuto, (===)) import qualified Polysemy.Time as Time-import Polysemy.Time (Days (Days), MilliSeconds (MilliSeconds), convert, mkDatetime)+import Polysemy.Time (Days (Days), Hours (Hours), MilliSeconds (MilliSeconds), convert, mkDatetime) import Torsor (add) import Helic.Data.Event (Event (Event))@@ -47,3 +47,4 @@ Nothing === appendIfValid (add (convert (MilliSeconds 100)) old) event2 historyLatest assertJust (historyLatest |> event2) (appendIfValid (add (convert (MilliSeconds 1100)) old) event2 historyLatest) assertJust (historyLatest |> eventNl) (appendIfValid now eventMixedNl historyLatest)+ Nothing === appendIfValid now (Event "me" "test" (add (convert (Hours (-1))) old) "event3") historyLatest
test/Helic/Test/LoadTest.hs view
@@ -37,4 +37,4 @@ ev5 <- event 6 assertJust ev5 =<< History.load 4 assertEq Nothing =<< History.load 11- assertEq (show <$> ([1..5] ++ [7..10] ++ [6 :: Int])) =<< fmap Event.content <$> History.get+ assertEq (show <$> ([1..5] ++ [7..10] ++ [6 :: Int])) . fmap Event.content =<< History.get