As found in PR #1264, it seems that exactprint-based import list modification seems to introduce an extra newline in certain situation.
Bisecting it in the master branch, this behaviour is first introduced in eb557b3.
Steps to reproduce
-
Checkout eb557b3 and build ghcide the binary and make sure your LSP client will use it as a language server executable.
-
Save the following as Lib.hs:
module Lib where
import Data.Vector ()
theFun = fromList
Make sure there is at least one newline between the module header and the import declaration; otherwise this bug won't occur.
-
Open Lib.hs and wait for the module to be loaded.
-
Apply Add fromList to Data.Vector code action.
Expected behaviour
fromList is added to the import list, without any modification to the lines except for import list itself, resulting in:
module Lib where
import Data.Vector (fromList)
theFun = fromList
Actual behaviour
An extra newline added between the module header and the import declaration:
module Lib where
import Data.Vector (fromList)
theFun = fromList
Note that there are two blank lines in-between instead of just one.