on master help sign in
Fix check for empty file path (#304)

I accidentally broke this on Windows in #303 by letting the two conversirons get out of sync.

commit64693eddd8fc3659036c3b9c1ddfd88ccc7b4619 authorMoritz Kiefer <moritz.kiefer@purelyfunctional.org> dateSat 4 Jan 2020, 01:25 (7 years ago) parent7e80629
2 files changed+13−1
src/Development/IDE/Types/Location.hs+4−1 test/exe/Main.hs+9
src/Development/IDE/Types/Location.hs+4−1
@@ -66,9 +66,12 @@ fromNormalizedFilePath (NormalizedFilePath fp) = fp
6666-- So we have our own wrapper here that supports empty filepaths.
6767uriToFilePath' :: Uri -> Maybe FilePath
6868uriToFilePath' uri
69− | uri == filePathToUri "" = Just ""
69+ | uri == fromNormalizedUri emptyPathUri = Just ""
7070 | otherwise = LSP.uriToFilePath uri
7171
72+emptyPathUri :: NormalizedUri
73+emptyPathUri = filePathToUri' ""
74+
7275filePathToUri' :: NormalizedFilePath -> NormalizedUri
7376filePathToUri' (NormalizedFilePath fp) = toNormalizedUri $ Uri $ T.pack $ LSP.fileScheme <> "//" <> platformAdjustToUriPath fp
7477 where
test/exe/Main.hs+9
@@ -18,6 +18,7 @@ import Development.IDE.GHC.Util
1818import qualified Data.Text as T
1919import Development.IDE.Test
2020import Development.IDE.Test.Runfiles
21+import Development.IDE.Types.Location
2122import Language.Haskell.LSP.Test
2223import Language.Haskell.LSP.Types
2324import Language.Haskell.LSP.Types.Capabilities
@@ -48,6 +49,7 @@ main = defaultMain $ testGroup "HIE"
4849 , pluginTests
4950 , preprocessorTests
5051 , thTests
52+ , unitTests
5153 ]
5254
5355initializeResponseTests :: TestTree
@@ -1306,3 +1308,10 @@ openTestDataDoc :: FilePath -> Session TextDocumentIdentifier
13061308openTestDataDoc path = do
13071309 source <- liftIO $ readFileUtf8 $ "test/data" </> path
13081310 openDoc' path "haskell" source
1311+
1312+unitTests :: TestTree
1313+unitTests = do
1314+ testGroup "Unit"
1315+ [ testCase "empty file path" $
1316+ uriToFilePath' (fromNormalizedUri $ filePathToUri' "") @?= Just ""
1317+ ]