Skip to content

Return completions lazily for massive savings #2217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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