File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,10 @@ import System.FilePath
82
82
import System.IO (hClose )
83
83
import System.IO.Temp
84
84
import Data.Maybe (catMaybes )
85
+ import qualified Control.Exception as E
86
+ import Control.DeepSeq ( NFData
87
+ , deepseq
88
+ )
85
89
86
90
descriptor :: PluginId -> PluginDescriptor
87
91
descriptor plId =
@@ -278,7 +282,12 @@ done, we want to switch back to GhcSessionDeps:
278
282
void $ runDecls stmt
279
283
return Nothing
280
284
281
- edits <- liftIO $ evalGhcEnv hscEnv' $ traverse (eval . first T. unpack) statements
285
+ edits <-
286
+ liftIO
287
+ $ (either (\ e -> [Just . T. pack . pad $ e]) id <$> )
288
+ $ strictTry
289
+ $ evalGhcEnv hscEnv'
290
+ $ traverse (eval . first T. unpack) statements
282
291
283
292
284
293
let workspaceEditsMap = Map. fromList [(_uri, List [evalEdit])]
@@ -287,6 +296,11 @@ done, we want to switch back to GhcSessionDeps:
287
296
288
297
return (WorkspaceApplyEdit , ApplyWorkspaceEditParams workspaceEdits)
289
298
299
+ strictTry :: NFData b => IO b -> IO (Either String b )
300
+ strictTry op = E. catch
301
+ (op >>= \ v -> return $! Right $! deepseq v v)
302
+ (\ (err :: E. SomeException ) -> return $! Left $ show err)
303
+
290
304
pad :: String -> String
291
305
pad = unlines . map (" -- " <> ) . lines
292
306
You can’t perform that action at this time.
0 commit comments