on master help sign in
Normalise filepaths to match haskell-lsp 0.19 (#266)

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).

commite86391244918019833b3cf14a6003a40cf9c56e5 authorMoritz Kiefer <moritz.kiefer@purelyfunctional.org> dateTue 17 Dec 2019, 10:59 (7 years ago) parenta698a6f
1 file changed+2−19
src/Development/IDE/Types/Location.hs+2−19
src/Development/IDE/Types/Location.hs+2−19
@@ -30,7 +30,6 @@ import Data.Maybe as Maybe
3030import Data.Hashable
3131import Data.String
3232import System.FilePath
33−import System.Info.Extra
3433import qualified Language.Haskell.LSP.Types as LSP
3534import Language.Haskell.LSP.Types as LSP (
3635 filePathToUri
@@ -49,25 +48,9 @@ instance IsString NormalizedFilePath where
4948 fromString = toNormalizedFilePath
5049
5150toNormalizedFilePath :: FilePath -> NormalizedFilePath
51+-- We want to keep empty paths instead of normalising them to "."
5252toNormalizedFilePath "" = NormalizedFilePath ""
53−toNormalizedFilePath fp = NormalizedFilePath $ normalise' fp
54− where
55− -- We do not use System.FilePath’s normalise here since that
56− -- also normalises things like the case of the drive letter
57− -- which NormalizedUri does not normalise so we get VFS lookup failures.
58− normalise' :: FilePath -> FilePath
59− normalise' = oneSlash . map (\c -> if isPathSeparator c then pathSeparator else c)
60−
61− -- Allow double slashes as the very first element of the path for UNC drives on Windows
62− -- otherwise turn adjacent slashes into one. These slashes often arise from dodgy CPP
63− oneSlash :: FilePath -> FilePath
64− oneSlash (x:xs) | isWindows = x : f xs
65− oneSlash xs = f xs
66−
67− f (x:y:xs) | isPathSeparator x, isPathSeparator y = f (x:xs)
68− f (x:xs) = x : f xs
69− f [] = []
70−
53+toNormalizedFilePath fp = NormalizedFilePath $ normalise fp
7154
7255fromNormalizedFilePath :: NormalizedFilePath -> FilePath
7356fromNormalizedFilePath (NormalizedFilePath fp) = fp