File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ import GHC.Stack
4242import Neovim hiding (err )
4343import Neovim.API.Text (Buffer (.. ), Window )
4444import System.Process (ProcessHandle )
45+ import Data.Bool (bool )
4546
4647deriving stock instance Ord Buffer
4748
@@ -143,6 +144,13 @@ instance MonadState CornelisState (Neovim CornelisEnv) where
143144 mv <- asks ce_state
144145 liftIO $ writeIORef mv a
145146
147+ data GiveResult
148+ = Give_String Text
149+ | Give_Paren
150+ | Give_NoParen
151+ deriving (Eq , Ord , Show )
152+
153+
146154data Response
147155 = DisplayInfo DisplayInfo
148156 | ClearHighlighting -- TokenBased
@@ -156,7 +164,7 @@ data Response
156164 }
157165 | JumpToError FilePath AgdaIndex
158166 | InteractionPoints [InteractionPoint Maybe ]
159- | GiveAction Text (InteractionPoint (Const () ))
167+ | GiveAction GiveResult (InteractionPoint (Const () ))
160168 | MakeCase MakeCase
161169 | SolveAll [Solution ]
162170 | Unknown Text Value
@@ -390,7 +398,9 @@ instance FromJSON Response where
390398 SolveAll <$> obj .: " solutions"
391399 " GiveAction" ->
392400 (obj .: " giveResult" ) >>= \ result ->
393- GiveAction <$> result .: " str" <*> obj .: " interactionPoint"
401+ GiveAction
402+ <$> (Give_String <$> result .: " str" <|> bool Give_NoParen Give_Paren <$> result .: " paren" )
403+ <*> obj .: " interactionPoint"
394404 " DisplayInfo" ->
395405 DisplayInfo <$> obj .: " info"
396406 " JumpToError" ->
Original file line number Diff line number Diff line change @@ -68,7 +68,12 @@ respond b (GiveAction result ip) = do
6868 Nothing -> reportError $ T. pack $ " Can't find interaction point " <> show i
6969 Just ip' -> do
7070 int <- getIpInterval b ip'
71- replaceInterval b int $ replaceQuestion result
71+ goalContents <- getGoalContents b ip'
72+ -- replacement <- case result of
73+ replaceInterval b int $ replaceQuestion $ case result of
74+ Give_String text -> text
75+ Give_Paren -> " (" <> goalContents <> " )"
76+ Give_NoParen -> goalContents
7277 load
7378-- Replace the interaction point with a result
7479respond b (SolveAll solutions) = do
You can’t perform that action at this time.
0 commit comments