@@ -206,13 +206,13 @@ mkAdditionalEditsCommand :: PluginId -> ExtendImport -> IO Command
206206mkAdditionalEditsCommand pId edits =
207207 mkLspCommand pId (CommandId extendImportCommandId) " extend import" (Just [toJSON edits])
208208
209- mkNameCompItem :: Uri -> Maybe T. Text -> Name -> ModuleName -> Maybe Type -> Maybe Backtick -> SpanDoc -> Maybe (LImportDecl GhcPs ) -> CompItem
209+ mkNameCompItem :: Uri -> Maybe T. Text -> OccName -> ModuleName -> Maybe Type -> Maybe Backtick -> SpanDoc -> Maybe (LImportDecl GhcPs ) -> CompItem
210210mkNameCompItem doc thingParent origName origMod thingType isInfix docs ! imp = CI {.. }
211211 where
212- compKind = occNameToComKind typeText $ occName origName
212+ compKind = occNameToComKind typeText origName
213213 importedFrom = Right $ showModName origMod
214- isTypeCompl = isTcOcc $ occName origName
215- label = showGhc origName
214+ isTypeCompl = isTcOcc origName
215+ label = stripPrefix $ showGhc origName
216216 insertText = case isInfix of
217217 Nothing -> case getArgText <$> thingType of
218218 Nothing -> label
@@ -345,10 +345,10 @@ cacheDataProducer uri packageState curMod globalEnv inScopeEnv limports deps = d
345345 toCompItem :: Parent -> Module -> ModuleName -> Name -> Maybe (LImportDecl GhcPs ) -> IO [CompItem ]
346346 toCompItem par m mn n imp' = do
347347 docs <- getDocumentationTryGhc packageState curMod deps n
348- let mbParent = case par of
349- NoParent -> Nothing
350- ParentIs n -> Just ( showNameWithoutUniques n)
351- FldParent n _ -> Just ( showNameWithoutUniques n)
348+ let ( mbParent, originName) = case par of
349+ NoParent -> ( Nothing , nameOccName n)
350+ ParentIs n' -> ( Just $ showNameWithoutUniques n', nameOccName n)
351+ FldParent n' lbl -> ( Just $ showNameWithoutUniques n', maybe (nameOccName n) mkVarOccFS lbl )
352352 tys <- catchSrcErrors (hsc_dflags packageState) " completion" $ do
353353 name' <- lookupName packageState m n
354354 return ( name' >>= safeTyThingType
@@ -361,7 +361,7 @@ cacheDataProducer uri packageState curMod globalEnv inScopeEnv limports deps = d
361361 [mkRecordSnippetCompItem uri mbParent ctxStr flds (ppr mn) docs imp']
362362 _ -> []
363363
364- return $ mkNameCompItem uri mbParent n mn ty Nothing docs imp'
364+ return $ mkNameCompItem uri mbParent originName mn ty Nothing docs imp'
365365 : recordCompls
366366
367367 (unquals,quals) <- getCompls rdrElts
@@ -588,7 +588,7 @@ getCompletions plId ideOpts CC {allModNamesAsNS, unqualCompls, qualCompls, impor
588588 -> return $ filtPragmaCompls (pragmaSuffix fullLine)
589589 | otherwise -> do
590590 let uniqueFiltCompls = nubOrdOn insertText filtCompls
591- compls <- mapM (mkCompl plId ideOpts . stripAutoGenerated ) uniqueFiltCompls
591+ compls <- mapM (mkCompl plId ideOpts) uniqueFiltCompls
592592 return $ filtModNameCompls
593593 ++ filtKeywordCompls
594594 ++ map ( toggleSnippets caps withSnippets) compls
@@ -657,16 +657,11 @@ openingBacktick line prefixModule prefixText Position { _character }
657657
658658-- | Under certain circumstance GHC generates some extra stuff that we
659659-- don't want in the autocompleted symbols
660- stripAutoGenerated :: CompItem -> CompItem
661- stripAutoGenerated ci =
662- ci {label = stripPrefix (label ci)}
663660 {- When e.g. DuplicateRecordFields is enabled, compiler generates
664661 names like "$sel:accessor:One" and "$sel:accessor:Two" to disambiguate record selectors
665662 https://ghc.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields/DuplicateRecordFields#Implementation
666663 -}
667-
668664-- TODO: Turn this into an alex lexer that discards prefixes as if they were whitespace.
669-
670665stripPrefix :: T. Text -> T. Text
671666stripPrefix name = T. takeWhile (/= ' :' ) $ go prefixes
672667 where
0 commit comments