@@ -11,6 +11,7 @@ module Ide.Plugin.ExplicitImports
11
11
( descriptor
12
12
, descriptorForModules
13
13
, abbreviateImportTitle
14
+ , squashedAbbreviateImportTitle
14
15
, Log (.. )
15
16
) where
16
17
@@ -174,11 +175,12 @@ lensResolveProvider _ _ _ _ _ rd = do
174
175
175
176
176
177
inlayHintProvider :: Recorder (WithPriority Log ) -> PluginMethodHandler IdeState 'Method_TextDocumentInlayHint
177
- inlayHintProvider _ state _ InlayHintParams {_textDocument = TextDocumentIdentifier {_uri}} = do
178
+ inlayHintProvider _ state _ InlayHintParams {_textDocument = TextDocumentIdentifier {_uri}, _range = visibleRange } = do
178
179
nfp <- getNormalizedFilePathE _uri
179
180
(ImportActionsResult {forLens, forResolve}, pm) <- runActionE " ImportActions" state $ useWithStaleE ImportActions nfp
180
181
let inlayHints = [ generateInlayHints newRange ie
181
182
| (range, int) <- forLens
183
+ , range < visibleRange
182
184
, Just newRange <- [toCurrentRange pm range]
183
185
, Just ie <- [forResolve IM. !? int]]
184
186
pure $ InL inlayHints
@@ -194,10 +196,10 @@ inlayHintProvider _ state _ InlayHintParams {_textDocument = TextDocumentIdentif
194
196
, _paddingRight = Nothing
195
197
, _data_ = Nothing
196
198
}
197
- mkLabel :: ImportEdit -> T. Text |? [InlayHintLabelPart ]
199
+ mkLabel :: ImportEdit -> T. Text |? [InlayHintLabelPart ]
198
200
mkLabel (ImportEdit {ieResType, ieText}) =
199
- let title ExplicitImport = abbreviateImportTitle $ ( T. intercalate " " . filter ( not . T. null ) . T. split isSpace . T. dropWhile ( /= ' ( ' )) ieText
200
- title RefineImport = T. intercalate " , " (T. lines ieText)
201
+ let title ExplicitImport = squashedAbbreviateImportTitle ieText
202
+ title RefineImport = T. intercalate " , " (T. lines ieText)
201
203
in InL $ title ieResType
202
204
203
205
@@ -445,7 +447,6 @@ isExplicitImport _ = False
445
447
maxColumns :: Int
446
448
maxColumns = 120
447
449
448
- -- | The title of the command is ideally the minimal explicit import decl, but
449
450
-- we don't want to create a really massive code lens (and the decl can be extremely large!).
450
451
-- So we abbreviate it to fit a max column size, and indicate how many more items are in the list
451
452
-- after the abbreviation
@@ -478,6 +479,10 @@ abbreviateImportTitle input =
478
479
else actualPrefix <> suffixText
479
480
in title
480
481
482
+ squashedAbbreviateImportTitle :: T. Text -> T. Text
483
+ squashedAbbreviateImportTitle ieText = abbreviateImportTitle $ (T. intercalate " " . filter (not . T. null ) . T. split isSpace . T. dropWhile (/= ' (' )) ieText
484
+
485
+ -- | The title of the command is ideally the minimal explicit import decl, but
481
486
--------------------------------------------------------------------------------
482
487
483
488
0 commit comments