From ebd9445ca5d33f722a4cf7946fcbe04d30b9d97a Mon Sep 17 00:00:00 2001 From: jneira Date: Fri, 5 Nov 2021 22:24:47 +0100 Subject: [PATCH] Add reproduction for #2290 --- plugins/hls-hlint-plugin/test/Main.hs | 6 ++++++ .../hls-hlint-plugin/test/testdata/TwoHintsAndComment.hs | 3 +++ plugins/hls-hlint-plugin/test/testdata/hie.yaml | 1 + 3 files changed, 10 insertions(+) create mode 100644 plugins/hls-hlint-plugin/test/testdata/TwoHintsAndComment.hs diff --git a/plugins/hls-hlint-plugin/test/Main.hs b/plugins/hls-hlint-plugin/test/Main.hs index 41b99c9734..94505295ad 100644 --- a/plugins/hls-hlint-plugin/test/Main.hs +++ b/plugins/hls-hlint-plugin/test/Main.hs @@ -139,6 +139,9 @@ suggestionsTests = , testCase "apply-refact preserve regular comments" $ runHlintSession "" $ do testRefactor "Comments.hs" "Redundant bracket" expectedComments + , testCase "[#2290] apply all hints works with a trailing comment" $ runHlintSession "" $ do + testRefactor "TwoHintsAndComment.hs" "Apply all hints" expectedComments2 + , testCase "applyAll is shown only when there is at least one diagnostic in range" $ runHlintSession "" $ do doc <- openDoc "TwoHints.hs" "haskell" _ <- waitForDiagnosticsFromSource doc "hlint" @@ -212,6 +215,9 @@ suggestionsTests = , "f = {- inline comment -}{- inline comment inside refactored code -} 1 -- ending comment", "" , "-- final comment" ] + expectedComments2 = [ "module TwoHintsAndComment where" + , "biggest items = foldr1 max -- the line above will show two hlint hints, \"eta reduce\" and \"use maximum\"" + ] expectedTypeApp = [ "module TypeApplication where", "" , "a = id @Int 1" ] diff --git a/plugins/hls-hlint-plugin/test/testdata/TwoHintsAndComment.hs b/plugins/hls-hlint-plugin/test/testdata/TwoHintsAndComment.hs new file mode 100644 index 0000000000..615e85f8e2 --- /dev/null +++ b/plugins/hls-hlint-plugin/test/testdata/TwoHintsAndComment.hs @@ -0,0 +1,3 @@ +module TwoHintsAndComments where + +biggest items = foldr1 max items -- the line above will show two hlint hints, "eta reduce" and "use maximum" diff --git a/plugins/hls-hlint-plugin/test/testdata/hie.yaml b/plugins/hls-hlint-plugin/test/testdata/hie.yaml index cd9c0df566..28e1a7bbc1 100644 --- a/plugins/hls-hlint-plugin/test/testdata/hie.yaml +++ b/plugins/hls-hlint-plugin/test/testdata/hie.yaml @@ -13,3 +13,4 @@ cradle: - "TwoHints" - "PatternKeyword" - "StrictData" + - "TwoHintsAndComment"