Skip to content

Commit

Permalink
Parenthesise type operators when extending import lists (#1212)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mrBliss authored Jan 15, 2021
1 parent 5578b8f commit 4b0e456
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ghcide/src/Development/IDE/Types/Exports.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ mkIdentInfos (AvailTC parent (n:nn) flds)
] ++
[ IdentInfo (pack (prettyPrint n)) (pack (printName n)) Nothing (isDataConName n)]
where
parentP = pack $ prettyPrint parent
parentP = pack $ printName parent

mkIdentInfos (AvailTC _ nn flds)
= [ IdentInfo (pack (prettyPrint n)) (pack (printName n)) Nothing (isDataConName n)
Expand Down
16 changes: 16 additions & 0 deletions ghcide/test/exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,22 @@ extendImportTests = testGroup "extend import actions"
, "import ModuleA (bar)"
, "foo = bar"
])
, testSession "extend import list with constructor of type operator" $ template
[]
("ModuleA.hs", T.unlines
[ "module ModuleA where"
, "import Data.Type.Equality ((:~:))"
, "x :: (:~:) [] []"
, "x = Refl"
])
(Range (Position 3 17) (Position 3 18))
["Add (:~:)(Refl) to the import list of Data.Type.Equality"]
(T.unlines
[ "module ModuleA where"
, "import Data.Type.Equality ((:~:)(Refl))"
, "x :: (:~:) [] []"
, "x = Refl"
])
]
where
codeActionTitle CodeAction{_title=x} = x
Expand Down

0 comments on commit 4b0e456

Please sign in to comment.