From c8b4c2bd35f3a0da19d66549e481628fee5476e5 Mon Sep 17 00:00:00 2001 From: Kirill Andreev Date: Sat, 9 May 2020 11:57:10 +0400 Subject: [PATCH] Fix comment )-truncation --- tools/lsp/squirrel/src/AST/Types.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/lsp/squirrel/src/AST/Types.hs b/tools/lsp/squirrel/src/AST/Types.hs index 257797866..349f8218f 100644 --- a/tools/lsp/squirrel/src/AST/Types.hs +++ b/tools/lsp/squirrel/src/AST/Types.hs @@ -217,7 +217,12 @@ c :: HasComments i => i -> Doc -> Doc c i d = case getComments i of [] -> d - cc -> block (map Text.init cc) $$ d + cc -> block (map removeSlashN cc) $$ d + where + removeSlashN txt = + if "\n" `Text.isSuffixOf` txt + then Text.init txt + else txt instance HasComments i => Pretty (Contract i) where pp = \case @@ -272,7 +277,7 @@ instance HasComments i => Pretty (Mutable i) where instance HasComments i => Pretty (Type i) where pp = \case TArrow i dom codom -> c i $ parens (pp dom `indent` "->" <+> pp codom) - TRecord i fields -> c i $ "record" <+> list fields + TRecord i fields -> c i $ "record [" `indent` block fields `above` "]" TVar i name -> c i $ pp name TSum i variants -> c i $ block variants TProduct i elements -> c i $ train " *" elements @@ -358,7 +363,7 @@ instance HasComments i => Pretty (QualifiedName i) where instance HasComments i => Pretty (Pattern i) where pp = \case - IsConstr i ctor arg -> c i $ pp ctor <> maybe empty pp arg + IsConstr i ctor arg -> c i $ pp ctor <+> maybe empty pp arg IsConstant i z -> c i $ pp z IsVar i name -> c i $ pp name IsCons i h t -> c i $ pp h <+> ("#" <+> pp t)