Skip to content

Commit b214278

Browse files
committed
Use Text directly for processes
1 parent ace226d commit b214278

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ library
3030
, hls-plugin-api ^>=1.3
3131
, lens
3232
, lsp
33-
, process
33+
, process-extras
3434
, text
3535

3636
default-language: Haskell2010

plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs

+6-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import Control.Monad.IO.Class
1515
import Data.Bifunctor (first)
1616
import Data.Maybe
1717
import qualified Data.Text as T
18+
import qualified Data.Text.IO as T
1819
import Development.IDE hiding (pluginHandlers)
1920
import Development.IDE.GHC.Compat as Compat hiding (Cpp)
2021
import qualified Development.IDE.GHC.Compat.Util as S
@@ -28,8 +29,8 @@ import Language.LSP.Types.Lens (HasTabSize (tabSize))
2829
import Ormolu
2930
import System.Exit
3031
import System.FilePath
31-
import System.IO (stderr, hPutStrLn)
32-
import System.Process
32+
import System.IO (stderr)
33+
import System.Process.Text (readProcessWithExitCode)
3334

3435
-- ---------------------------------------------------------------------
3536

@@ -63,11 +64,11 @@ provider ideState typ contents fp fo = withIndefiniteProgress title Cancellable
6364
]
6465
<> map ("-o" <>) fileOpts
6566
)
66-
(T.unpack contents)
67-
hPutStrLn stderr err
67+
contents
68+
T.hPutStrLn stderr err
6869
case exitCode of
6970
ExitSuccess ->
70-
pure . Right $ makeDiffTextEdit contents $ T.pack out
71+
pure . Right $ makeDiffTextEdit contents out
7172
ExitFailure n ->
7273
pure . Left . responseError $ "Fourmolu failed with exit code " <> T.pack (show n)
7374
else do

0 commit comments

Comments
 (0)