diff --git a/plugins/default/src/Ide/Plugin/Eval.hs b/plugins/default/src/Ide/Plugin/Eval.hs index 28a16f383e..e91396c03d 100644 --- a/plugins/default/src/Ide/Plugin/Eval.hs +++ b/plugins/default/src/Ide/Plugin/Eval.hs @@ -117,7 +117,14 @@ extractMatches = goSearch 0 . maybe [] T.lines r = Range p p' p = Position line 0 p' = Position (line + spliceLength) 0 - spliceLength = length (takeWhile looksLikeSplice (l : ll)) + spliceLines = takeWhile looksLikeSplice (l : ll) + -- Don't include the last line if it's an empty comment. + -- Do this to preserve spacing between consecutive splices + isEmptyComment = (== "--") + spliceLength = case spliceLines of + [] -> 0 + ls | isEmptyComment (last ls) -> length ls - 1 + | otherwise -> length ls provider :: CodeLensProvider provider lsp _state plId CodeLensParams {_textDocument} = response $ do diff --git a/test/functional/Eval.hs b/test/functional/Eval.hs index 7c5e6b62c0..78762599e4 100644 --- a/test/functional/Eval.hs +++ b/test/functional/Eval.hs @@ -91,6 +91,8 @@ tests = testGroup $ goldenTest "T25.hs" , testCase "local imports" $ goldenTest "T26.hs" + , testCase "Preserves one empty comment line after prompt" + $ goldenTest "T27.hs" ] goldenTest :: FilePath -> IO () diff --git a/test/testdata/eval/T27.hs b/test/testdata/eval/T27.hs new file mode 100644 index 0000000000..c1d68eba66 --- /dev/null +++ b/test/testdata/eval/T27.hs @@ -0,0 +1,4 @@ +module T27 where + +-- >>> () +-- diff --git a/test/testdata/eval/T27.hs.expected b/test/testdata/eval/T27.hs.expected new file mode 100644 index 0000000000..e931c55c29 --- /dev/null +++ b/test/testdata/eval/T27.hs.expected @@ -0,0 +1,5 @@ +module T27 where + +-- >>> () +-- () +--