Skip to content

'IntelliSense on Functions' tooltip does not appear when in parentheses related to other construct #10941

Closed

Description

@JordanMarr

I have found a few scenarios where the new functions parameter tooltip does not work using VS 16.9 preview 3:

  • Computation Expressions
  • Lambda Expressions

Repro steps

Computation Expressions

The new preview IntelliSense context tooltip does not appear within computation expressions.
I've verified this against the following CEs:

  • async
  • asyncResult
  • Fable.GroupingPanel

Lambda Expressions

It also does not appear when placed within the body of a lambda expression.
This works:

let add n1 n2 = n1 + n2
let sum = add 1 2 // The new tooltip correctly appears

This does not work:

let lst = [1; 2; 3]
let mapped = 
    lst |> List.map (fun n ->
        let sum = add 1 2 // New tooltip does not appear; instead, shows old tooltip
        n.ToString()
    )

Expected behavior

Should always show the new function parameter preview that shows all parameters.

Actual behavior

Sometimes reverts to the old preview that only shows the current parameter.

  • Windows 10
  • Tested on .NET Core 3.1 and .NET Standard projects
  • Visual Studio Professional 16.9 Preview 3

Activity

  1. cartermp commented on Jan 25, 2021

    @cartermp
    Contributor

    Computation expressions is covered here: #10835

    Should be in the 16.9 full release, unsure about a specific preview

    Within parens in a lambda is an interesting issue that I anticipated would arise but wasn't sure of the impact. Should be fun to take a look

  2. changed the title [-]'IntelliSense on Functions' tooltip does not appear in certain contexts[/-] [+]'IntelliSense on Functions' tooltip does not appear when in parentheses related to other construct[/+] on Jan 25, 2021
  3. added this to the Backlog milestone on Jan 25, 2021
  4. cartermp commented on Jan 26, 2021

    @cartermp
    Contributor

    Just to add a screenshot, this is what's going on:

    image

    This is because TryRangeOfFunctionOrMethodBeingApplied has a bug where it picks List.map rather than sum.

    Additionally, TryIdentOfPipelineContainingPosAndNumArgsApplied is making an assumption causing the number of reported curried arguments to be incorrect.

  5. cartermp commented on Jan 27, 2021

    @cartermp
    Contributor

    Marking this here for now, a quirk I noticed when editing code int he compiler. I can't say if it's related yet:

    image

  6. cartermp commented on Jan 27, 2021

    @cartermp
    Contributor

    Using #10957 to track the issue I noticed and another.

  7. cartermp commented on Jan 27, 2021

    @cartermp
    Contributor

    Thanks for the report. The issue as-reported is fixed here: #10954

    We're nearing a code freeze for VS 16.9 so I'll see if I can cherry pick the fix into the release. If not, then this would be in the 16.10 previews.

    There are a few other quirks tracked in #10957 - if you notice additional issues, please file new ones or comment on that thread. I can move things around/create issues as needed.

  8. modified the milestones: Backlog, 16.10 on Feb 6, 2021
  9. cartermp commented on Mar 10, 2021

    @cartermp
    Contributor

    Hmm, I'm actually going to re-open this because the "old" tooltip will still trigger for me. I noticed this happening again and it's less common, but still triggers. It's actually due to something else. Consider the following:

    type C() =
        member _.M(x) = ()
    
    
    let c = C()
    c.M(sqrt)// <<- caret is after 't'!

    When you hit the space key, signature help for M is given instead of for sqrt. What's happening is that the syntax tree APIs are working from the outside in and noticing that M(... is considered valid for a tooltip and then shows that. We really need to dive further in and only show the most relevant one

  10. JordanMarr commented on Mar 10, 2021

    @JordanMarr
    Author

    Hmm, I'm actually going to re-open this because the "old" tooltip will still trigger for me.

    Here's another scenario: the tooltip doesn't show -- it appears to be related to the generic argument being present:

        /// Tries to cast an object to a given type; throws with the given error message if it fails.
        let tryConvert<'T> (descriptor: string) (value: obj) : 'T =
            try
                Convert.ChangeType(value, typeof<'T>) :?> 'T
            with ex ->
                let msg = sprintf "Unable to convert '%s' with value %A" descriptor value
                raise (new Exception(msg, ex))
    
        // Tooltip does NOT show when the generic argument is present:
        let result= (box 123) |> tryConvert<string> "numbers"
    
        // Tooltip does show properly here:
        let result : string = (box 123) |> tryConvert "numbers"
    

    Edit: This is using VS 16.9.0

  11. JordanMarr commented on Mar 10, 2021

    @JordanMarr
    Author

    I have another one for you: tooltip doesn't appear for composed functions.

        let prependStar (txt: string) = "*" + txt
        let appendStar (txt: string) = txt + "*"
        let addStars = prependStar >> appendStar
    
        // Good
        let result1 = prependStar "ABC"
    
        // Good
        let result2 = appendStar "ABC"
    
        // Bad - No Intellisense tooltip
        let result3 = addStars "ABC" 
    
    
  12. cartermp commented on Mar 10, 2021

    @cartermp
    Contributor

    The last case is unfortunately not inherent to the language feature. The problem is that addStars is a function value and the information about that is lossy. The compiler doesn't assign parameters to it since it's a function value.

    One possible approach here is to remove the check for parameters and artificially construct one. I'll play around with that and see if it's the appropriate tweak.

  13. cartermp commented on Mar 10, 2021

    @cartermp
    Contributor

    Yeah, that's not going to be reasonable to do compared with the other cases. I'll file an issue for this but it'll probably just be low priority since it's not a common occurrence + much more difficult to pull off.

  14. JordanMarr commented on Mar 10, 2021

    @JordanMarr
    Author

    Another one that I noticed that's maybe not worth messing with, but I might as well mention it now:
    it doesn't show the tooltip if there is a character directly after the cursor, like an end paren.

    let doStuff (txt: string) = printfn txt
    let doStuffLazy = lazy (doStuff ) // <-- hitting space here while the cursor is touching the end paren prevents tooltip
    

    The workaround is pretty easy though -- just make sure to add a space before the closing paren.

  15. cartermp commented on Mar 10, 2021

    @cartermp
    Contributor

    This is also fixed in #11200:

    sighelp1

  16. JordanMarr commented on Mar 10, 2021

    @JordanMarr
    Author

    Yessss!

  17. cartermp commented on Mar 10, 2021

    @cartermp
    Contributor

    Closing out again since #11200 is merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions