From 4f24bf5e27312dfb59e228ef9b235caea3f01361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20LEESCO?= Date: Wed, 21 Jan 2026 19:22:51 +0100 Subject: [PATCH 1/2] parenthesize for CornelisSolve --- src/Lib.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Lib.hs b/src/Lib.hs index 4928b24..13b12d0 100644 --- a/src/Lib.hs +++ b/src/Lib.hs @@ -45,6 +45,12 @@ respondToHelperFunction (HelperFunction sig) = setreg "\"" sig respondToHelperFunction (Version ver) = reportInfo ver respondToHelperFunction _ = pure () +parenthesize :: Text -> Text +parenthesize t = + let trimmed = T.strip t + in if T.any (== ' ') trimmed && not (T.isPrefixOf "(" trimmed && T.isSuffixOf ")" trimmed) + then "(" <> trimmed <> ")" + else trimmed respond :: Buffer -> Response -> Neovim CornelisEnv () -- Update the buffer's goal map @@ -68,7 +74,7 @@ respond b (GiveAction result ip) = do Nothing -> reportError $ T.pack $ "Can't find interaction point " <> show i Just ip' -> do int <- getIpInterval b ip' - replaceInterval b int $ replaceQuestion result + replaceInterval b int $ parenthesize $ replaceQuestion result load -- Replace the interaction point with a result respond b (SolveAll solutions) = do @@ -77,7 +83,7 @@ respond b (SolveAll solutions) = do Nothing -> reportError $ T.pack $ "Can't find interaction point " <> show i Just ip -> do int <- getIpInterval b ip - replaceInterval b int $ replaceQuestion ex + replaceInterval b int $ parenthesize $ replaceQuestion ex load respond b ClearHighlighting = do -- delete what we know about goto positions and stored extmarks From c36b655754ef4bd4f4ffc29702f67406cb29328c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20LEESCO?= Date: Wed, 21 Jan 2026 20:16:17 +0100 Subject: [PATCH 2/2] remove parenthesize on GiveAction --- src/Lib.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Lib.hs b/src/Lib.hs index 13b12d0..59dfcc7 100644 --- a/src/Lib.hs +++ b/src/Lib.hs @@ -74,7 +74,7 @@ respond b (GiveAction result ip) = do Nothing -> reportError $ T.pack $ "Can't find interaction point " <> show i Just ip' -> do int <- getIpInterval b ip' - replaceInterval b int $ parenthesize $ replaceQuestion result + replaceInterval b int $ replaceQuestion result load -- Replace the interaction point with a result respond b (SolveAll solutions) = do