From 5d0f9c615197f9ad17eb9fecf9c487eb2610e083 Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Tue, 17 Dec 2019 09:24:58 +0100 Subject: [PATCH] Normalise filepaths to match haskell-lsp 0.19 haskell-lsp 0.19 has started to normalise file paths completely so we need to make sure that NormalizedFilePath agrees with that, otherwise, we get a bunch of test failures on the daml repo (they are not specific to DAML, but atm ghcide CI does not run windows). --- src/Development/IDE/Types/Location.hs | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/Development/IDE/Types/Location.hs b/src/Development/IDE/Types/Location.hs index 13a736aad..c00d18c49 100644 --- a/src/Development/IDE/Types/Location.hs +++ b/src/Development/IDE/Types/Location.hs @@ -50,24 +50,7 @@ instance IsString NormalizedFilePath where toNormalizedFilePath :: FilePath -> NormalizedFilePath toNormalizedFilePath "" = NormalizedFilePath "" -toNormalizedFilePath fp = NormalizedFilePath $ normalise' fp - where - -- We do not use System.FilePath’s normalise here since that - -- also normalises things like the case of the drive letter - -- which NormalizedUri does not normalise so we get VFS lookup failures. - normalise' :: FilePath -> FilePath - normalise' = oneSlash . map (\c -> if isPathSeparator c then pathSeparator else c) - - -- Allow double slashes as the very first element of the path for UNC drives on Windows - -- otherwise turn adjacent slashes into one. These slashes often arise from dodgy CPP - oneSlash :: FilePath -> FilePath - oneSlash (x:xs) | isWindows = x : f xs - oneSlash xs = f xs - - f (x:y:xs) | isPathSeparator x, isPathSeparator y = f (x:xs) - f (x:xs) = x : f xs - f [] = [] - +toNormalizedFilePath fp = NormalizedFilePath $ normalise fp fromNormalizedFilePath :: NormalizedFilePath -> FilePath fromNormalizedFilePath (NormalizedFilePath fp) = fp