Skip to content

Commit 86b3726

Browse files
authored
Return completions lazily for massive savings (#2217)
1 parent b6d1df2 commit 86b3726

File tree

1 file changed

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

1 file changed

+6
-6
lines changed

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ showModName = T.pack . moduleNameString
151151
-- Nothing Nothing Nothing Nothing (Just insertText) (Just Snippet)
152152
-- Nothing Nothing Nothing Nothing Nothing
153153

154-
mkCompl :: PluginId -> IdeOptions -> CompItem -> IO CompletionItem
154+
mkCompl :: PluginId -> IdeOptions -> CompItem -> CompletionItem
155155
mkCompl
156156
pId
157157
IdeOptions {..}
@@ -165,7 +165,7 @@ mkCompl
165165
docs,
166166
additionalTextEdits
167167
} = do
168-
mbCommand <- mkAdditionalEditsCommand pId `traverse` additionalTextEdits
168+
let mbCommand = mkAdditionalEditsCommand pId `fmap` additionalTextEdits
169169
let ci = CompletionItem
170170
{_label = label,
171171
_kind = kind,
@@ -184,7 +184,7 @@ mkCompl
184184
_commitCharacters = Nothing,
185185
_command = mbCommand,
186186
_xdata = Nothing}
187-
return $ removeSnippetsWhen (isJust isInfix) ci
187+
removeSnippetsWhen (isJust isInfix) ci
188188

189189
where kind = Just compKind
190190
docs' = imported : spanDocToMarkdown docs
@@ -196,8 +196,8 @@ mkCompl
196196
MarkupContent MkMarkdown $
197197
T.intercalate sectionSeparator docs'
198198

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

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

0 commit comments

Comments
 (0)