From 901a29b58c809c4686e69e9621e81e161fcf0286 Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Thu, 20 May 2021 16:17:52 -0700 Subject: [PATCH 1/2] Fix record layout --- ghcide/src/Development/IDE/GHC/ExactPrint.hs | 4 ++-- plugins/hls-tactics-plugin/test/CodeAction/IntrosSpec.hs | 3 +++ plugins/hls-tactics-plugin/test/golden/LayoutRec.expected.hs | 5 +++++ plugins/hls-tactics-plugin/test/golden/LayoutRec.hs | 5 +++++ 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 plugins/hls-tactics-plugin/test/golden/LayoutRec.expected.hs create mode 100644 plugins/hls-tactics-plugin/test/golden/LayoutRec.hs diff --git a/ghcide/src/Development/IDE/GHC/ExactPrint.hs b/ghcide/src/Development/IDE/GHC/ExactPrint.hs index c74c94dd6c..3783aa5cab 100644 --- a/ghcide/src/Development/IDE/GHC/ExactPrint.hs +++ b/ghcide/src/Development/IDE/GHC/ExactPrint.hs @@ -203,8 +203,8 @@ needsParensSpace HsMultiIf{} = (All False, All False) needsParensSpace HsLet{} = (All False, All True) needsParensSpace HsDo{} = (All False, All False) needsParensSpace ExplicitList{} = (All False, All False) -needsParensSpace RecordCon{} = (All False, All False) -needsParensSpace RecordUpd{} = mempty +needsParensSpace RecordCon{} = (All False, All True) +needsParensSpace RecordUpd{} = (All False, All True) needsParensSpace _ = mempty diff --git a/plugins/hls-tactics-plugin/test/CodeAction/IntrosSpec.hs b/plugins/hls-tactics-plugin/test/CodeAction/IntrosSpec.hs index 254ec68522..da2aaaa273 100644 --- a/plugins/hls-tactics-plugin/test/CodeAction/IntrosSpec.hs +++ b/plugins/hls-tactics-plugin/test/CodeAction/IntrosSpec.hs @@ -14,3 +14,6 @@ spec = do describe "golden" $ do introsTest 2 8 "GoldenIntros" + describe "layout" $ do + introsTest 4 24 "LayoutRec" + diff --git a/plugins/hls-tactics-plugin/test/golden/LayoutRec.expected.hs b/plugins/hls-tactics-plugin/test/golden/LayoutRec.expected.hs new file mode 100644 index 0000000000..9818d23e5e --- /dev/null +++ b/plugins/hls-tactics-plugin/test/golden/LayoutRec.expected.hs @@ -0,0 +1,5 @@ +data Pair a b = Pair {pa :: a, pb :: b} + +p :: Pair (a -> a) (a -> b -> c -> b) +p = Pair {pa = _, pb = \ a b c -> _} + diff --git a/plugins/hls-tactics-plugin/test/golden/LayoutRec.hs b/plugins/hls-tactics-plugin/test/golden/LayoutRec.hs new file mode 100644 index 0000000000..47a9895c2e --- /dev/null +++ b/plugins/hls-tactics-plugin/test/golden/LayoutRec.hs @@ -0,0 +1,5 @@ +data Pair a b = Pair {pa :: a, pb :: b} + +p :: Pair (a -> a) (a -> b -> c -> b) +p = Pair {pa = _, pb = _} + From 6deb9a27e1b4d0604e135f1042674ba9b0ceacfa Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Thu, 20 May 2021 16:19:17 -0700 Subject: [PATCH 2/2] Don't change the record update rules --- ghcide/src/Development/IDE/GHC/ExactPrint.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ghcide/src/Development/IDE/GHC/ExactPrint.hs b/ghcide/src/Development/IDE/GHC/ExactPrint.hs index 3783aa5cab..b231044bc5 100644 --- a/ghcide/src/Development/IDE/GHC/ExactPrint.hs +++ b/ghcide/src/Development/IDE/GHC/ExactPrint.hs @@ -204,7 +204,7 @@ needsParensSpace HsLet{} = (All False, All True) needsParensSpace HsDo{} = (All False, All False) needsParensSpace ExplicitList{} = (All False, All False) needsParensSpace RecordCon{} = (All False, All True) -needsParensSpace RecordUpd{} = (All False, All True) +needsParensSpace RecordUpd{} = mempty needsParensSpace _ = mempty