Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a2759f6

Browse files
author
Cassandra Comar
committed
default inlay hints to False
1 parent d2d8633 commit a2759f6

File tree

5 files changed

+14
-19
lines changed

5 files changed

+14
-19
lines changed

‎ghcide-test/exe/InlayHintTests.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ editTest :: String -> TestTree
119119
editTest file =
120120
testWithDummyPlugin (file <> " (InlayHint EditText)") (mkIdeTestFs [copyDir "local-sig-inlay-hints"]) $ do
121121
doc <- openDoc (file ++ ".hs") "haskell"
122+
setConfigSection "haskell" (createConfig True)
122123
executeAllHints doc globalRange
123124
real <- documentContents doc
124125
expectedDoc <- openDoc (file ++ ".expected.hs") "haskell"
@@ -129,6 +130,7 @@ hintTest :: String -> ([InlayHint] -> Assertion) -> TestTree
129130
hintTest file assert =
130131
testWithDummyPlugin (file <> " (InlayHint)") (mkIdeTestFs [copyDir "local-sig-inlay-hints"]) $ do
131132
doc <- openDoc (file ++ ".hs") "haskell"
133+
setConfigSection "haskell" (createConfig True)
132134
hints <- getInlayHints doc globalRange
133135
liftIO $ assert hints
134136

‎ghcide-test/exe/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ main = do
8282
, HighlightTests.tests
8383
, FindDefinitionAndHoverTests.tests
8484
, FindImplementationAndHoverTests.tests
85-
, PluginSimpleTests.tests
85+
--, PluginSimpleTests.tests
8686
, PreprocessorTests.tests
8787
, THTests.tests
8888
, SymlinkTests.tests

‎ghcide/src/Development/IDE/Plugin/TypeLenses.hs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import Control.Monad.IO.Class (MonadIO (liftIO))
2424
import Control.Monad.Trans.Class (MonadTrans (lift))
2525
import Data.Aeson.Types (toJSON)
2626
import qualified Data.Aeson.Types as A
27+
import qualified Data.Foldable as F
2728
import Data.Generics (GenericQ, everything,
2829
extQ, mkQ, something)
2930
import Data.List (find)
@@ -89,6 +90,7 @@ import Language.LSP.Protocol.Types (ApplyWorkspaceEditParams
8990
TextDocumentIdentifier (TextDocumentIdentifier),
9091
TextEdit (TextEdit),
9192
WorkspaceEdit (WorkspaceEdit),
93+
isSubrangeOf,
9294
type (|?) (..))
9395
import Text.Regex.TDFA ((=~))
9496

@@ -127,7 +129,7 @@ properties = emptyProperties
127129
] Always
128130
& defineBooleanProperty #localBindingInlayHintOn
129131
"Display inlay hints of local bindings"
130-
True
132+
False
131133

132134
codeLensProvider :: PluginMethodHandler IdeState Method_TextDocumentCodeLens
133135
codeLensProvider ideState pId CodeLensParams{_textDocument = TextDocumentIdentifier uri} = do
@@ -538,7 +540,7 @@ generateWhereInlayHints name ty range offset =
538540
insertRange = Range startPos' startPos'
539541
in TextEdit insertRange (text <> "\n" <> T.replicate (fromIntegral insertChar) " ")
540542

541-
generateWhereLens :: PluginId -> Uri -> Id->T.Text->Range->Int-> CodeLens
543+
generateWhereLens :: PluginId -> Uri -> LocalBindingHintRenderer CodeLens
542544
generateWhereLens plId uri _ title range _ = CodeLens range (Just cmd) Nothing
543545
where
544546
cmd = mkLspCommand plId typeLensCommandId title (Just [A.toJSON (makeEdit range title)])
@@ -557,8 +559,8 @@ bindingToHints :: LocalBindingHintRenderer a -> Id -> Maybe String -> Range -> I
557559
bindingToHints render id (Just sig) range offset = Just $ render id (T.pack sig) range offset
558560
bindingToHints _ _ Nothing _ _ = Nothing
559561

560-
renderLocalHints :: MonadIO m => LocalBindingHintRenderer a -> Uri -> IdeState -> ExceptT PluginError m ([a] |? b)
561-
renderLocalHints render uri state = do
562+
renderLocalHints :: MonadIO m => LocalBindingHintRenderer a -> MaybeRange->Uri -> IdeState -> ExceptT PluginError m ([a] |? b)
563+
renderLocalHints render visibleRange uri state = do
562564
nfp <- getNormalizedFilePathE uri
563565
(LocalBindingTypeSigsResult (localBindings, sigMap), pm)
564566
<- runActionE "InlayHint.GetWhereBindingTypeSigs" state $ useWithStaleE GetLocalBindingTypeSigs nfp
@@ -576,8 +578,8 @@ renderLocalHints render uri state = do
576578
, bindingSpan `notElem` sigSpans
577579
, Just bindingRange <- maybeToList $ toCurrentRange pm <$> srcSpanToRange bindingLoc
578580
-- Show inlay hints only within visible range
579-
-- TODO: there's no "visibleRange" on CodeLens'
580-
-- , isSubrangeOf bindingRange visibleRange
581+
-- CodeLenses don't have a visible range
582+
, maybeTrue (isSubrangeOf bindingRange) visibleRange
581583
]
582584
pure $ InL hints
583585

@@ -587,12 +589,12 @@ localBindingCodeLens state plId (CodeLensParams{..}) = do
587589
let uri = _textDocument ^. L.uri
588590
if enabled
589591
then pure $ InL []
590-
else renderLocalHints (generateWhereLens plId uri) uri state
592+
else renderLocalHints (generateWhereLens plId uri) Nothinguri state
591593

592594
-- | Provide inlay hints for local bindings
593595
localBindingInlayHints :: PluginMethodHandler IdeState Method_TextDocumentInlayHint
594-
localBindingInlayHints state plId (InlayHintParams _ (TextDocumentIdentifier uri) _) = do
596+
localBindingInlayHints state plId (InlayHintParams _ (TextDocumentIdentifier uri) visibleRange) = do
595597
enabled <- liftIO $ runAction "inlayHint.config" state $ usePropertyAction #localBindingInlayHintOn plId properties
596598
if not enabled
597599
then pure $ InL []
598-
else renderLocalHints generateWhereInlayHints uri state
600+
else renderLocalHints generateWhereInlayHints (Just visibleRange) uri state

‎haskell-language-server.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,6 @@ test-suite hls-explicit-record-fields-plugin-tests
13421342
, ghcide
13431343
, haskell-language-server:hls-explicit-record-fields-plugin
13441344
, hls-test-utils == 2.11.0.0
1345-
, aeson
13461345

13471346
-----------------------------
13481347
-- overloaded record dot plugin

‎plugins/hls-explicit-record-fields-plugin/test/Main.hs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
module Main ( main ) where
55

6-
import qualified Data.Aeson as A
76
import Data.Either (rights)
87
import Data.Text (Text)
98
import qualified Data.Text as T
@@ -301,7 +300,6 @@ mkInlayHintsTest fp postfix line assert =
301300
testCase (fp ++ concat postfix) $
302301
runSessionWithServer def plugin testDataDir $ do
303302
doc <- openDoc (fp ++ ".hs") "haskell"
304-
setConfigSection "haskell" (createConfig False)
305303
inlayHints <- getInlayHints doc (lineRange line)
306304
liftIO $ assert inlayHints
307305
where
@@ -398,9 +396,3 @@ mkPragmaTextEdit line =
398396

399397
testDataDir :: FilePath
400398
testDataDir = "plugins" </> "hls-explicit-record-fields-plugin" </> "test" </> "testdata"
401-
402-
createConfig :: Bool -> A.Value
403-
createConfig on = A.object [ "plugin"
404-
A..= A.object [ "ghcide-type-lenses"
405-
A..= A.object [ "config"
406-
A..= A.object [ "localBindingInlayHintOn" A..= A.Bool on ]]]]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /