@@ -36,6 +36,7 @@ test = testGroup "explicit-fields"
3636 , mkTestNoAction " Puns" " Puns" 12 10 12 31
3737 , mkTestNoAction " Infix" " Infix" 11 11 11 31
3838 , mkTestNoAction " Prefix" " Prefix" 10 11 10 28
39+ , mkTest " PolymorphicRecordConstruction" " PolymorphicRecordConstruction" 15 5 15 15
3940 ]
4041 , testGroup " inlay hints"
4142 [ mkInlayHintsTest " Construction" Nothing 16 $ \ ih -> do
@@ -212,6 +213,31 @@ test = testGroup "explicit-fields"
212213 , _tooltip = Just $ InL " Expand record wildcard"
213214 , _paddingLeft = Just True
214215 }]
216+ , mkInlayHintsTest " PolymorphicRecordConstruction" Nothing 15 $ \ ih -> do
217+ let mkLabelPart' = mkLabelPartOffsetLengthSub1 " PolymorphicRecordConstruction"
218+ foo <- mkLabelPart' 5 4 " foo="
219+ bar <- mkLabelPart' 6 4 " bar="
220+ baz <- mkLabelPart' 7 4 " baz="
221+ (@?=) ih
222+ [ defInlayHint { _position = Position 15 11
223+ , _label = InR [ foo ]
224+ , _textEdits = Just [ mkLineTextEdit " MyRec { foo = a, bar = b, baz = c }" 15 5 16 ]
225+ , _tooltip = Just $ InL " Expand positional record"
226+ , _paddingLeft = Nothing
227+ }
228+ , defInlayHint { _position = Position 15 13
229+ , _label = InR [ bar ]
230+ , _textEdits = Just [ mkLineTextEdit " MyRec { foo = a, bar = b, baz = c }" 15 5 16 ]
231+ , _tooltip = Just $ InL " Expand positional record"
232+ , _paddingLeft = Nothing
233+ }
234+ , defInlayHint { _position = Position 15 15
235+ , _label = InR [ baz ]
236+ , _textEdits = Just [ mkLineTextEdit " MyRec { foo = a, bar = b, baz = c }" 15 5 16 ]
237+ , _tooltip = Just $ InL " Expand positional record"
238+ , _paddingLeft = Nothing
239+ }
240+ ]
215241 ]
216242 ]
217243
@@ -285,10 +311,10 @@ mkLabelPart offset fp line start value = do
285311 uri = canonicalizeUri $ toUri (testDataDir </> (fp ++ " .hs" ))
286312 location uri line char = Location uri (Range (Position line char) (Position line (char + offset value)))
287313
288- mkLabelPartOffsetLength :: FilePath -> UInt -> UInt -> Text -> IO InlayHintLabelPart
314+ mkLabelPartOffsetLength :: FilePath -> UInt -> UInt -> Text -> IO InlayHintLabelPart
289315mkLabelPartOffsetLength = mkLabelPart (fromIntegral . T. length )
290316
291- mkLabelPartOffsetLengthSub1 :: FilePath -> UInt -> UInt -> Text -> IO InlayHintLabelPart
317+ mkLabelPartOffsetLengthSub1 :: FilePath -> UInt -> UInt -> Text -> IO InlayHintLabelPart
292318mkLabelPartOffsetLengthSub1 = mkLabelPart (fromIntegral . subtract 1 . T. length )
293319
294320commaPart :: InlayHintLabelPart
0 commit comments