git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
[psc-ide] Fix unicode encoding of json responses
commit5def0199bc0b57431ff7426ea126f8ab564e05c3 authorChristoph Hegemann <christoph.hegemann1337@gmail.com> dateThu 7 Jul 2016, 12:09 (10 years ago) parent7174a75
3 files changed+13−19
psc-ide-client/Main.hs+6−16 psc-ide-server/Main.hs+4−3 purescript.cabal+3
psc-ide-client/Main.hs+6−16
@@ -5,16 +5,15 @@ import Prelude ()
55import Prelude.Compat
66
77import Control.Exception
8−import Data.Text (Text)
9−import qualified Data.Text as T
10−import qualified Data.Text.IO as T
11−import Data.Version (showVersion)
8+import qualified Data.ByteString.Char8 as BS8
9+import qualified Data.Text.IO as T
10+import Data.Version (showVersion)
1211import Network
1312import Options.Applicative
1413import System.Exit
1514import System.IO
1615
17−import qualified Paths_purescript as Paths
16+import qualified Paths_purescript as Paths
1817
1918data Options = Options
2019 { optionsPort :: PortID
@@ -41,16 +40,7 @@ client port = do
4140 ("Couldn't connect to psc-ide-server on port: " ++
4241 show port ++ " Error: " ++ show e) >>
4342 exitFailure)
44− cmd <- T.getLine
45− -- Temporary fix for emacs windows bug
46− let cleanedCmd = removeSurroundingTicks cmd
47− --
48− T.hPutStrLn h cleanedCmd
49− res <- T.hGetLine h
50− putStrLn (T.unpack res)
43+ T.hPutStrLn h =<< T.getLine
44+ BS8.putStrLn =<< BS8.hGetLine h
5145 hFlush stdout
5246 hClose h
53−
54−-- TODO: Fix this in the emacs plugin by using a real process over shellcommands
55−removeSurroundingTicks :: Text -> Text
56−removeSurroundingTicks = T.dropWhile (== '\'') . T.dropWhileEnd (== '\'')
psc-ide-server/Main.hs+4−3
@@ -23,9 +23,11 @@ module Main where
2323
2424import Protolude
2525
26+import qualified Data.Aeson as Aeson
2627import Control.Concurrent.STM
2728import "monad-logger" Control.Monad.Logger
2829import qualified Data.Text.IO as T
30+import qualified Data.ByteString.Lazy.Char8 as BS8
2931import Data.Version (showVersion)
3032import Language.PureScript.Ide
3133import Language.PureScript.Ide.Util
@@ -121,9 +123,8 @@ startServer port env = withSocketsDo $ do
121123 -- $(logDebug) ("Answer was: " <> T.pack (show result))
122124 liftIO (hFlush stdout)
123125 case result of
124− -- What function can I use to clean this up?
125− Right r -> liftIO $ T.hPutStrLn h (encodeT r)
126− Left err -> liftIO $ T.hPutStrLn h (encodeT err)
126+ Right r -> liftIO $ BS8.hPutStrLn h (Aeson.encode r)
127+ Left err -> liftIO $ BS8.hPutStrLn h (Aeson.encode err)
127128 Nothing -> do
128129 $(logDebug) ("Parsing the command failed. Command: " <> cmd)
129130 liftIO $ do
purescript.cabal+3
@@ -428,6 +428,8 @@ executable psc-ide-server
428428 other-modules: Paths_purescript
429429 other-extensions:
430430 build-depends: base >=4 && <5,
431+ aeson >= 0.8 && < 0.12,
432+ bytestring -any,
431433 purescript -any,
432434 base-compat >=0.6.0,
433435 directory -any,
@@ -450,6 +452,7 @@ executable psc-ide-client
450452 other-extensions:
451453 build-depends: base >=4 && <5,
452454 base-compat >=0.6.0,
455+ bytestring -any,
453456 mtl -any,
454457 network -any,
455458 optparse-applicative >= 0.12.1,