@@ -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