File tree Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -296,6 +296,7 @@ test-suite ghcide-tests
296
296
build-depends :
297
297
aeson,
298
298
base,
299
+ binary,
299
300
bytestring,
300
301
containers,
301
302
directory,
Original file line number Diff line number Diff line change @@ -57,7 +57,9 @@ module Development.IDE.Core.Shake(
57
57
ProgressEvent (.. ),
58
58
DelayedAction , mkDelayedAction ,
59
59
IdeAction (.. ), runIdeAction ,
60
- mkUpdater
60
+ mkUpdater ,
61
+ -- Exposed for testing.
62
+ Q (.. ),
61
63
) where
62
64
63
65
import Development.Shake hiding (ShakeValue , doesFileExist , Info )
@@ -792,7 +794,14 @@ isBadDependency x
792
794
newtype Q k = Q (k , NormalizedFilePath )
793
795
deriving (Eq ,Hashable ,NFData , Generic )
794
796
795
- instance Binary k => Binary (Q k )
797
+ instance Binary k => Binary (Q k ) where
798
+ put (Q (k, fp)) = put (k, fp)
799
+ get = do
800
+ (k, fp) <- get
801
+ -- The `get` implementation of NormalizedFilePath
802
+ -- does not handle empty file paths so we
803
+ -- need to handle this ourselves here.
804
+ pure (Q (k, toNormalizedFilePath' fp))
796
805
797
806
instance Show k => Show (Q k ) where
798
807
show (Q (k, file)) = show k ++ " ; " ++ fromNormalizedFilePath file
Original file line number Diff line number Diff line change @@ -16,12 +16,14 @@ import qualified Control.Lens as Lens
16
16
import Control.Monad
17
17
import Control.Monad.IO.Class (liftIO )
18
18
import Data.Aeson (FromJSON , Value )
19
+ import qualified Data.Binary as Binary
19
20
import Data.Foldable
20
21
import Data.List.Extra
21
22
import Data.Maybe
22
23
import Data.Rope.UTF16 (Rope )
23
24
import qualified Data.Rope.UTF16 as Rope
24
25
import Development.IDE.Core.PositionMapping (fromCurrent , toCurrent )
26
+ import Development.IDE.Core.Shake (Q (.. ))
25
27
import Development.IDE.GHC.Util
26
28
import qualified Data.Text as T
27
29
import Data.Typeable
@@ -2832,6 +2834,8 @@ unitTests = do
2832
2834
, testCase " from empty path URI" $ do
2833
2835
let uri = Uri " file://"
2834
2836
uriToFilePath' uri @?= Just " "
2837
+ , testCase " Key with empty file path roundtrips via Binary" $
2838
+ Binary. decode (Binary. encode (Q (() , emptyFilePath))) @?= Q (() , emptyFilePath)
2835
2839
]
2836
2840
2837
2841
positionMappingTests :: TestTree
You can’t perform that action at this time.
0 commit comments