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
8282import System.IO (hClose )
8383import System.IO.Temp
8484import Data.Maybe (catMaybes )
85+ import qualified Control.Exception as E
86+ import Control.DeepSeq ( NFData
87+ , deepseq
88+ )
8589
8690descriptor :: PluginId -> PluginDescriptor
8791descriptor plId =
@@ -278,7 +282,12 @@ done, we want to switch back to GhcSessionDeps:
278282 void $ runDecls stmt
279283 return Nothing
280284
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
282291
283292
284293 let workspaceEditsMap = Map. fromList [(_uri, List [evalEdit])]
@@ -287,6 +296,11 @@ done, we want to switch back to GhcSessionDeps:
287296
288297 return (WorkspaceApplyEdit , ApplyWorkspaceEditParams workspaceEdits)
289298
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+
290304pad :: String -> String
291305pad = unlines . map (" -- " <> ) . lines
292306
You can’t perform that action at this time.
0 commit comments