From 443650705cc24c9654bcdcc7d4791aa58ac660a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= Date: Wed, 12 Aug 2015 10:44:41 +0200 Subject: [PATCH] Fix #532, Use first component in cabal file for dangling modules in cabal projects --- Language/Haskell/GhcMod/Target.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Language/Haskell/GhcMod/Target.hs b/Language/Haskell/GhcMod/Target.hs index 2b9379d..66bb80f 100644 --- a/Language/Haskell/GhcMod/Target.hs +++ b/Language/Haskell/GhcMod/Target.hs @@ -188,6 +188,7 @@ targetGhcOptions crdl sefnmn = do mcs <- cached cradleRootDir resolvedComponentsCache comps let mdlcs = moduleComponents mcs `zipMap` Set.toList sefnmn + cns = map gmcName comps candidates = findCandidates $ map snd mdlcs let noCandidates = Set.null candidates @@ -195,8 +196,8 @@ targetGhcOptions crdl sefnmn = do if noCandidates && noModuleHasAnyAssignment then do - gmLog GmWarning "" $ strDoc $ "Could not find a component assignment, falling back to guessed GHC options." - sandboxOpts crdl + gmLog GmWarning "" $ strDoc $ "Could not find a component assignment, falling back to picking first component in cabal file." + return $ gmcGhcOpts $ fromJust $ Map.lookup (head cns) mcs else do when noCandidates $ throwError $ GMECabalCompAssignment mdlcs