Skip to content

Commit d70a1db

Browse files
committed
Add typeText for local completions of type/class declarations
helps with #2270
1 parent ddf5b02 commit d70a1db

File tree

1 file changed

+6
-5
lines changed
  • ghcide/src/Development/IDE/Plugin/Completions

1 file changed

+6
-5
lines changed

ghcide/src/Development/IDE/Plugin/Completions/Logic.hs

+6-5
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ mkCompl
179179
_tags = Nothing,
180180
_detail =
181181
case (typeText, provenance) of
182-
(Just t,_) -> Just $ colon <> t
182+
(Just t,_) -> Just $ colon <> t
183183
(_, ImportedFrom mod) -> Just $ "from " <> mod
184-
(_, DefinedIn mod) -> Just $ "from " <> mod
185-
_ -> Nothing,
184+
(_, DefinedIn mod) -> Just $ "from " <> mod
185+
_ -> Nothing,
186186
_documentation = documentation,
187187
_deprecated = Nothing,
188188
_preselect = Nothing,
@@ -448,12 +448,12 @@ localCompletionsForParsedModule uri pm@ParsedModule{pm_parsed_source = L _ HsMod
448448
[mkComp id CiVariable Nothing
449449
| VarPat _ id <- listify (\(_ :: Pat GhcPs) -> True) pat_lhs]
450450
TyClD _ ClassDecl{tcdLName, tcdSigs} ->
451-
mkComp tcdLName CiInterface Nothing :
451+
mkComp tcdLName CiInterface (Just $ ppr tcdLName) :
452452
[ mkComp id CiFunction (Just $ ppr typ)
453453
| L _ (ClassOpSig _ _ ids typ) <- tcdSigs
454454
, id <- ids]
455455
TyClD _ x ->
456-
let generalCompls = [mkComp id cl Nothing
456+
let generalCompls = [mkComp id cl (Just $ ppr $ tcdLName x)
457457
| id <- listify (\(_ :: Located(IdP GhcPs)) -> True) x
458458
, let cl = occNameToComKind Nothing (rdrNameOcc $ unLoc id)]
459459
-- here we only have to look at the outermost type
@@ -678,6 +678,7 @@ uniqueCompl candidate unique =
678678
else compare (importedFrom candidate, insertText candidate) (importedFrom unique, insertText unique)
679679
other -> other
680680
where
681+
-- This is an inaccurate predicate - some local completions do not have typeText
681682
isLocalCompletion ci = isJust(typeText ci)
682683

683684
importedFrom :: CompItem -> T.Text

0 commit comments

Comments
 (0)