From 0a0cd8041e82136b9e733d689d628641dc535065 Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Tue, 12 Jan 2016 21:33:20 +0300 Subject: [PATCH 1/2] Set file encoding to uft8 in Lint Fixes #722 --- Language/Haskell/GhcMod/Lint.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Language/Haskell/GhcMod/Lint.hs b/Language/Haskell/GhcMod/Lint.hs index 5241e5c..f217772 100644 --- a/Language/Haskell/GhcMod/Lint.hs +++ b/Language/Haskell/GhcMod/Lint.hs @@ -10,6 +10,7 @@ import Language.Haskell.HLint3 import Language.Haskell.GhcMod.Utils (withMappedFile) import Language.Haskell.Exts.Pretty (prettyPrint) +import System.IO -- | Checking syntax of a target file using hlint. -- Warnings and errors are returned. @@ -20,7 +21,9 @@ lint :: IOish m lint opt file = ghandle handler $ withMappedFile file $ \tempfile -> do (flags, classify, hint) <- liftIO $ argsSettings $ optLintHlintOpts opt - res <- liftIO $ parseModuleEx flags file =<< Just `fmap` readFile tempfile + hSrc <- liftIO $ openFile tempfile ReadMode + liftIO $ hSetEncoding hSrc utf8 + res <- liftIO $ parseModuleEx flags file =<< Just `fmap` hGetContents hSrc case res of Right m -> pack . map show $ applyHints classify hint [m] Left ParseError{parseErrorLocation=loc, parseErrorMessage=err} -> From 5425a0966680b21ff19d49e9d0bf47fcf6e10cbb Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Tue, 12 Jan 2016 22:09:33 +0300 Subject: [PATCH 2/2] [#722] Get encoding from hlint options --- Language/Haskell/GhcMod/Lint.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Language/Haskell/GhcMod/Lint.hs b/Language/Haskell/GhcMod/Lint.hs index f217772..f6c549f 100644 --- a/Language/Haskell/GhcMod/Lint.hs +++ b/Language/Haskell/GhcMod/Lint.hs @@ -22,7 +22,7 @@ lint opt file = ghandle handler $ withMappedFile file $ \tempfile -> do (flags, classify, hint) <- liftIO $ argsSettings $ optLintHlintOpts opt hSrc <- liftIO $ openFile tempfile ReadMode - liftIO $ hSetEncoding hSrc utf8 + liftIO $ hSetEncoding hSrc (encoding flags) res <- liftIO $ parseModuleEx flags file =<< Just `fmap` hGetContents hSrc case res of Right m -> pack . map show $ applyHints classify hint [m]