File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed
plugins/hls-cabal-plugin/src/Ide/Plugin Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -335,7 +335,7 @@ gotoDefinition ideState _ msgParam = do
335
335
cabalAddCodeAction :: Recorder (WithPriority Log ) -> PluginMethodHandler IdeState 'LSP.Method_TextDocumentCodeAction
336
336
cabalAddCodeAction recorder state plId (CodeActionParams _ _ (TextDocumentIdentifier uri) _ CodeActionContext {_diagnostics= diags}) = do
337
337
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
339
339
case suggestions of
340
340
[] -> pure $ InL []
341
341
_ ->
Original file line number Diff line number Diff line change @@ -141,7 +141,9 @@ addDependencySuggestCodeAction
141
141
addDependencySuggestCodeAction plId verTxtDocId suggestions haskellFilePath cabalFilePath gpd = do
142
142
buildTargets <- liftIO $ getBuildTargets gpd cabalFilePath haskellFilePath
143
143
case buildTargets of
144
+ -- If there are no build targets found, run `cabal-add` command with default behaviour
144
145
[] -> pure $ mkCodeAction cabalFilePath Nothing <$> suggestions
146
+ -- Otherwise provide actions for all found targets
145
147
targets -> pure $ concat [mkCodeAction cabalFilePath (Just $ buildTargetToStringRepr target) <$>
146
148
suggestions | target <- targets]
147
149
where
@@ -196,8 +198,8 @@ addDependencySuggestCodeAction plId verTxtDocId suggestions haskellFilePath caba
196
198
-- > "Perhaps you need to add ‘split’ to the build-depends in your .cabal file."
197
199
--
198
200
-- 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)
201
203
where
202
204
msg :: T. Text
203
205
msg = _message diag
You can’t perform that action at this time.
0 commit comments