Skip to content

Commit

Permalink
Fix virtual file name adding .hs extension (haskell#364)
Browse files Browse the repository at this point in the history
Problem: virtualFileName always adds a .hs extension to the filename.

Solution: Use takeExtensios instead to use the original file extension.

Co-authored-by: Heitor Toledo Lassarote de Paula <[email protected]>
  • Loading branch information
jneira and heitor-lassarote authored Nov 3, 2021
1 parent 39f9711 commit 0f389b5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lsp-types/src/Language/LSP/VFS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module Language.LSP.VFS
, changeChars
) where

import Control.Lens hiding ( parts )
import Control.Lens hiding ( (<.>), parts )
import Control.Monad
import Data.Char (isUpper, isAlphaNum)
import Data.Text ( Text )
Expand Down Expand Up @@ -247,7 +247,7 @@ virtualFileName prefix uri (VirtualFile _ file_ver _) =
padLeft n num =
let numString = show num
in replicate (n - length numString) '0' ++ numString
in prefix </> basename ++ "-" ++ padLeft 5 file_ver ++ "-" ++ show (hash uri_raw) ++ ".hs"
in prefix </> basename ++ "-" ++ padLeft 5 file_ver ++ "-" ++ show (hash uri_raw) <.> takeExtensions basename

-- | Write a virtual file to a temporary file if it exists in the VFS.
persistFileVFS :: VFS -> J.NormalizedUri -> Maybe (FilePath, IO ())
Expand Down

0 comments on commit 0f389b5

Please sign in to comment.