Skip to content

Commit ae6a060

Browse files
committed
docs
1 parent 310226f commit ae6a060

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ gotoDefinition ideState _ msgParam = do
335335
cabalAddCodeAction :: Recorder (WithPriority Log) -> PluginMethodHandler IdeState 'LSP.Method_TextDocumentCodeAction
336336
cabalAddCodeAction recorder state plId (CodeActionParams _ _ (TextDocumentIdentifier uri) _ CodeActionContext{_diagnostics=diags}) = do
337337
maxCompls <- fmap maxCompletions . liftIO $ runAction "cabal.cabal-add" state getClientConfigAction
338-
let suggestions = concatMap (\diag -> CabalAdd.hiddenPackageSuggestion maxCompls diag) diags
338+
let suggestions = take maxCompls $ concatMap CabalAdd.hiddenPackageSuggestion diags
339339
case suggestions of
340340
[] -> pure $ InL []
341341
_ ->

plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/CabalAdd.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ addDependencySuggestCodeAction
141141
addDependencySuggestCodeAction plId verTxtDocId suggestions haskellFilePath cabalFilePath gpd = do
142142
buildTargets <- liftIO $ getBuildTargets gpd cabalFilePath haskellFilePath
143143
case buildTargets of
144+
-- If there are no build targets found, run `cabal-add` command with default behaviour
144145
[] -> pure $ mkCodeAction cabalFilePath Nothing <$> suggestions
146+
-- Otherwise provide actions for all found targets
145147
targets -> pure $ concat [mkCodeAction cabalFilePath (Just $ buildTargetToStringRepr target) <$>
146148
suggestions | target <- targets]
147149
where
@@ -196,8 +198,8 @@ addDependencySuggestCodeAction plId verTxtDocId suggestions haskellFilePath caba
196198
-- > "Perhaps you need to add ‘split’ to the build-depends in your .cabal file."
197199
--
198200
-- Will turn into @[("split", "")]@
199-
hiddenPackageSuggestion :: Int -> Diagnostic -> [(T.Text, T.Text)]
200-
hiddenPackageSuggestion maxCompletions diag = take maxCompletions $ getMatch (msg =~ regex)
201+
hiddenPackageSuggestion :: Diagnostic -> [(T.Text, T.Text)]
202+
hiddenPackageSuggestion diag = getMatch (msg =~ regex)
201203
where
202204
msg :: T.Text
203205
msg = _message diag

0 commit comments

Comments
 (0)