Skip to content

Commit 64693ed

Browse files
authored
Fix check for empty file path (#304)
I accidentally broke this on Windows in #303 by letting the two conversirons get out of sync.
1 parent 7e80629 commit 64693ed

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Development/IDE/Types/Location.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,12 @@ fromNormalizedFilePath (NormalizedFilePath fp) = fp
6666
-- So we have our own wrapper here that supports empty filepaths.
6767
uriToFilePath' :: Uri -> Maybe FilePath
6868
uriToFilePath' uri
69-
| uri == filePathToUri "" = Just ""
69+
| uri == fromNormalizedUri emptyPathUri = Just ""
7070
| otherwise = LSP.uriToFilePath uri
7171

72+
emptyPathUri :: NormalizedUri
73+
emptyPathUri = filePathToUri' ""
74+
7275
filePathToUri' :: NormalizedFilePath -> NormalizedUri
7376
filePathToUri' (NormalizedFilePath fp) = toNormalizedUri $ Uri $ T.pack $ LSP.fileScheme <> "//" <> platformAdjustToUriPath fp
7477
where

test/exe/Main.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import Development.IDE.GHC.Util
1818
import qualified Data.Text as T
1919
import Development.IDE.Test
2020
import Development.IDE.Test.Runfiles
21+
import Development.IDE.Types.Location
2122
import Language.Haskell.LSP.Test
2223
import Language.Haskell.LSP.Types
2324
import Language.Haskell.LSP.Types.Capabilities
@@ -48,6 +49,7 @@ main = defaultMain $ testGroup "HIE"
4849
, pluginTests
4950
, preprocessorTests
5051
, thTests
52+
, unitTests
5153
]
5254

5355
initializeResponseTests :: TestTree
@@ -1306,3 +1308,10 @@ openTestDataDoc :: FilePath -> Session TextDocumentIdentifier
13061308
openTestDataDoc 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+
]

0 commit comments

Comments
 (0)