Skip to content

Add optional width parameter for FSharpCheckFileResults.GetToolTip #13772

Closed
@nojaf

Description

Is your feature request related to a problem? Please describe.

When the IDE gets a tooltip via FSharpCheckFileResults.GetToolTip, it will eventually print a layout from NicePrint.

Describe the solution you'd like

let rec FormatItemDescriptionToToolTipElement displayFullName (infoReader: InfoReader) ad m denv (item: ItemWithInst) =
let g = infoReader.g
let amap = infoReader.amap
let denv = SimplerDisplayEnv denv
let xml = GetXmlCommentForItem infoReader m item.Item
match item.Item with
| Item.ImplicitOp(_, { contents = Some(TraitConstraintSln.FSMethSln(vref=vref)) }) ->
// operator with solution
FormatItemDescriptionToToolTipElement displayFullName infoReader ad m denv { item with Item = Item.Value vref }
| Item.Value vref | Item.CustomBuilder (_, vref) ->
let prettyTyparInst, resL = NicePrint.layoutQualifiedValOrMember denv infoReader item.TyparInstantiation vref
let remarks = OutputFullName displayFullName pubpathOfValRef fullDisplayTextOfValRefAsLayout vref
let tpsL = FormatTyparMapping denv prettyTyparInst
let tpsL = List.map toArray tpsL
let resL = toArray resL
let remarks = toArray remarks
ToolTipElement.Single(resL, xml, tpsL, remarks=remarks)
// Union tags (constructors)
| Item.UnionCase(ucinfo, _) ->
let uc = ucinfo.UnionCase
let unionTy = generalizedTyconRef g ucinfo.TyconRef
let recd = uc.RecdFields
let layout =
wordL (tagText (FSComp.SR.typeInfoUnionCase())) ^^
NicePrint.layoutTyconRef denv ucinfo.TyconRef ^^
sepL (tagPunctuation ".") ^^
wordL (tagUnionCase (ConvertValLogicalNameToDisplayNameCore uc.Id.idText) |> mkNav uc.DefinitionRange) ^^
RightL.colon ^^
(if List.isEmpty recd then emptyL else NicePrint.layoutUnionCases denv infoReader ucinfo.TyconRef recd ^^ WordL.arrow) ^^
NicePrint.layoutType denv unionTy
let layout = toArray layout
ToolTipElement.Single (layout, xml)

To a certain degree, it is possible to control the width of a layout before it gets transformed into a tooltip.
Using Display.squashTo 80 after NicePrint.layoutType denv unionTy for example.

I'd like to be able to pass in an option width that when present squashes the layout to get a better tooltip view.

Describe alternatives you've considered

I'm not really sure what the alternatives could be here.

Metadata

Assignees

No one assigned

    Labels

    Area-Compiler-ServiceVarious compiler service issues which do not belong to other labels/areas.Feature Request

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Add optional width parameter for FSharpCheckFileResults.GetToolTip · Issue #13772 · dotnet/fsharp