Skip to content

Commit

Permalink
Return completions lazily for massive savings (#2217)
Browse files Browse the repository at this point in the history
  • Loading branch information
pepeiborra committed Sep 20, 2021
1 parent b6d1df2 commit 86b3726
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ghcide/src/Development/IDE/Plugin/Completions/Logic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ showModName = T.pack . moduleNameString
-- Nothing Nothing Nothing Nothing (Just insertText) (Just Snippet)
-- Nothing Nothing Nothing Nothing Nothing

mkCompl :: PluginId -> IdeOptions -> CompItem -> IO CompletionItem
mkCompl :: PluginId -> IdeOptions -> CompItem -> CompletionItem
mkCompl
pId
IdeOptions {..}
Expand All @@ -165,7 +165,7 @@ mkCompl
docs,
additionalTextEdits
} = do
mbCommand <- mkAdditionalEditsCommand pId `traverse` additionalTextEdits
let mbCommand = mkAdditionalEditsCommand pId `fmap` additionalTextEdits
let ci = CompletionItem
{_label = label,
_kind = kind,
Expand All @@ -184,7 +184,7 @@ mkCompl
_commitCharacters = Nothing,
_command = mbCommand,
_xdata = Nothing}
return $ removeSnippetsWhen (isJust isInfix) ci
removeSnippetsWhen (isJust isInfix) ci

where kind = Just compKind
docs' = imported : spanDocToMarkdown docs
Expand All @@ -196,8 +196,8 @@ mkCompl
MarkupContent MkMarkdown $
T.intercalate sectionSeparator docs'

mkAdditionalEditsCommand :: PluginId -> ExtendImport -> IO Command
mkAdditionalEditsCommand pId edits = pure $
mkAdditionalEditsCommand :: PluginId -> ExtendImport -> Command
mkAdditionalEditsCommand pId edits =
mkLspCommand pId (CommandId extendImportCommandId) "extend import" (Just [toJSON edits])

mkNameCompItem :: Uri -> Maybe T.Text -> OccName -> ModuleName -> Maybe Type -> Maybe Backtick -> SpanDoc -> Maybe (LImportDecl GhcPs) -> CompItem
Expand Down Expand Up @@ -616,7 +616,7 @@ getCompletions plId ideOpts CC {allModNamesAsNS, anyQualCompls, unqualCompls, qu
| otherwise -> do
-- assumes that nubOrdBy is stable
let uniqueFiltCompls = nubOrdBy uniqueCompl filtCompls
compls <- mapM (mkCompl plId ideOpts) uniqueFiltCompls
let compls = map (mkCompl plId ideOpts) uniqueFiltCompls
return $ filtModNameCompls
++ filtKeywordCompls
++ map (toggleSnippets caps config) compls
Expand Down

0 comments on commit 86b3726

Please sign in to comment.