Skip to content

Commit b89a4f9

Browse files
committed
Return completions lazily for massive savings (#2217)
1 parent 559451b commit b89a4f9

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ showModName = T.pack . moduleNameString
164164
-- Nothing Nothing Nothing Nothing (Just insertText) (Just Snippet)
165165
-- Nothing Nothing Nothing Nothing Nothing
166166

167-
mkCompl :: PluginId -> IdeOptions -> CompItem -> IO CompletionItem
167+
mkCompl :: PluginId -> IdeOptions -> CompItem -> CompletionItem
168168
mkCompl
169169
pId
170170
IdeOptions {..}
@@ -178,7 +178,7 @@ mkCompl
178178
docs,
179179
additionalTextEdits
180180
} = do
181-
mbCommand <- mkAdditionalEditsCommand pId `traverse` additionalTextEdits
181+
let mbCommand = mkAdditionalEditsCommand pId `fmap` additionalTextEdits
182182
let ci = CompletionItem
183183
{_label = label,
184184
_kind = kind,
@@ -197,7 +197,7 @@ mkCompl
197197
_commitCharacters = Nothing,
198198
_command = mbCommand,
199199
_xdata = Nothing}
200-
return $ removeSnippetsWhen (isJust isInfix) ci
200+
removeSnippetsWhen (isJust isInfix) ci
201201

202202
where kind = Just compKind
203203
docs' = imported : spanDocToMarkdown docs
@@ -209,8 +209,8 @@ mkCompl
209209
MarkupContent MkMarkdown $
210210
T.intercalate sectionSeparator docs'
211211

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

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

0 commit comments

Comments
 (0)