ionide / ionide-vscode-fsharp

VS Code plugin for F# development
http://ionide.io
MIT License
864 stars 279 forks source link

Parameter Names Inlay Hints sometimes overwriting code #1706

Closed mjlshen closed 2 years ago

mjlshen commented 2 years ago

Disclaimer: I'm new to F#, so not 100% sure if this is a bug, but it sure feels like one

Describe the bug

I'm trying to read in 8 integers from the console via:

Seq.init 8 (fun _ -> int(System.Console.In.ReadLine())

However, with with "FSharp.inlayHints.parameterNames": true, this confusingly shows in VSCode as:

// the count parameter name hint makes sense, not sure what's happening after System.Console
Seq.init count =8 (fun _ -> int(System.Console.InConsole.InCon

Stranger still, there's no such problem if I write it instead with something like:

open System

Seq.init 8 (fun _ -> int(Console.In.ReadLine()))

Steps to reproduce

  1. Make a brand new *.fsx file in VSCode with "FSharp.inlayHints.parameterNames": true
  2. Write some code, but include a line like Seq.init 8 (fun _ -> int(System.Console.In.ReadLine()) anywhere
  3. Can toggle parameter name inlay hints to see it "correctly" when hints are disabled

Expected behaviour

It's possible I'm supposed to open System? This may be myself doing an anti-pattern because I'm new to F#. Otherwise my expected behavior would be to not override the existing text

Machine info

baronfel commented 2 years ago

Thanks for reporting, I can sometimes reproduce this myself. At least often enough to where it's annoying. I don't think it's anything that you've done wrong, I think it's more likely a bug in the generation of the inlay hint or it's injection into the document you're viewing. In the meantime as a workaround, consider setting the inlay hints to toggle when you press Cmd+Alt, which you can do either by hovering over an inlay hint to show a tooltip and clicking the appropriate option in the suggestions we offer, or by manually setting the editor.inlayHints.enabled setting to offUnlessPressed. That will let you default to no inlay hints, but when you want to know a parameter name, or want to see a type hint, you can press that key combination and see them momentarily.

Krzysztof-Cieslak commented 2 years ago

This doesn't really sound like a problem with Ionide - we don't control inlay hints behaviour; we're just providing data for it. If it's still happening, please open an issue with reproduction on the VSCode repository itself.

baronfel commented 2 years ago

It would also be interesting to see if this changes when we do move to the LSP-based hints instead of our custom hints.