diff --git a/cabal.project b/cabal.project index 16e4d040a9..e535b882ae 100644 --- a/cabal.project +++ b/cabal.project @@ -137,4 +137,4 @@ if impl(ghc >= 9.5) semigroupoids:base, stm-hamt:transformers, entropy:Cabal, - + diff --git a/plugins/hls-class-plugin/src/Ide/Plugin/Class/CodeLens.hs b/plugins/hls-class-plugin/src/Ide/Plugin/Class/CodeLens.hs index 3f7facf668..44d3857c86 100644 --- a/plugins/hls-class-plugin/src/Ide/Plugin/Class/CodeLens.hs +++ b/plugins/hls-class-plugin/src/Ide/Plugin/Class/CodeLens.hs @@ -1,6 +1,7 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE OverloadedLists #-} {-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-overlapping-patterns #-} module Ide.Plugin.Class.CodeLens where @@ -90,7 +91,18 @@ codeLens state plId CodeLensParams{..} = pluginResponse $ do getBindSpanWithoutSig ClsInstDecl{..} = let bindNames = mapMaybe go (bagToList cid_binds) go (L l bind) = case bind of - FunBind{..} -> Just $ L l fun_id + FunBind{..} + -- `Generated` tagged for Template Haskell, + -- here we filter out nonsence generated bindings + -- that are nonsense for displaying code lenses. + -- + -- See https://github.com/haskell/haskell-language-server/issues/3319 +#if MIN_VERSION_ghc(9,5,0) + | not $ isGenerated (mg_ext fun_matches) +#else + | not $ isGenerated (mg_origin fun_matches) +#endif + -> Just $ L l fun_id _ -> Nothing -- Existed signatures' name sigNames = concat $ mapMaybe (\(L _ r) -> getSigName r) cid_sigs