Skip to content

Commit e149404

Browse files
committed
Parenthesise type operators when extending import lists
Fixes #1211. When extending the import of a type operator with one of its constructors, don't forget to put parentheses around the type operator.
1 parent 5578b8f commit e149404

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

ghcide/src/Development/IDE/Types/Exports.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ mkIdentInfos (AvailTC parent (n:nn) flds)
5858
] ++
5959
[ IdentInfo (pack (prettyPrint n)) (pack (printName n)) Nothing (isDataConName n)]
6060
where
61-
parentP = pack $ prettyPrint parent
61+
parentP = pack $ printName parent
6262

6363
mkIdentInfos (AvailTC _ nn flds)
6464
= [ IdentInfo (pack (prettyPrint n)) (pack (printName n)) Nothing (isDataConName n)

ghcide/test/exe/Main.hs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,6 +1300,22 @@ extendImportTests = testGroup "extend import actions"
13001300
, "import ModuleA (bar)"
13011301
, "foo = bar"
13021302
])
1303+
, testSession "extend import list with multiple choices" $ template
1304+
[]
1305+
("ModuleA.hs", T.unlines
1306+
[ "module ModuleA where"
1307+
, "import Data.Type.Equality ((:~:))"
1308+
, "x :: (:~:) [] []"
1309+
, "x = Refl"
1310+
])
1311+
(Range (Position 3 17) (Position 3 18))
1312+
["Add (:~:)(Refl) to the import list of Data.Type.Equality"]
1313+
(T.unlines
1314+
[ "module ModuleA where"
1315+
, "import Data.Type.Equality ((:~:)(Refl))"
1316+
, "x :: (:~:) [] []"
1317+
, "x = Refl"
1318+
])
13031319
]
13041320
where
13051321
codeActionTitle CodeAction{_title=x} = x

0 commit comments

Comments
 (0)