Fsharp: VS2019 autocompletion commits keywords on space

Created on 7 May 2019  路  6Comments  路  Source: dotnet/fsharp

Problem

Completion is committed with space for keywords only. This is annoying behavior in a language where short names are common, as short names (let a =) are often replaced with keywords (let and =).

Repro / Actual behavior

  1. Create new F# .Net Standard library.
  2. Entering 'a' brings up a completion list with selected item "and". Entering space then completes it.
  3. Entering 'b' brings up a completion list with selected item "box". Entering space doesn't complete it.
  4. A word gets completed by space if and only if it is a keyword (any word highlighted blue in VS by default).

Expected behavior

Preferably space should not commit a completion for any items.

Alternatively, if some people want space to commit, there should be an option to disable it under Tools -> Options -> Text Editor -> F# -> Intellisense.

Related information

needs repro

Most helpful comment

Sorry for delay. I can't repro the exact text in the OP. Here is one that happens reliably.

Completion1

All 6 comments

@charlesroddie can you give an example of where completion is triggered on let a? Doing it as a local binding, script file, in a library, or above the main function in a console app doesn't trigger it.

Looking at the code, I think a quick fix might be able to address this, but having a repro would help.

Sorry for delay. I can't repro the exact text in the OP. Here is one that happens reliably.

Completion1

a-z, space and delete:
Completion2

A workaround is Ctrl-Alt-Space to toggle from completion mode to suggestion mode.
https://blogs.msdn.microsoft.com/zainnab/2010/01/22/intellisense-suggestion-mode/

This issue also affects C# so is perhaps a global VS setting? I will close this as not F# specific but if the setting is controlled on a per-language basis then I can reopen @cartermp .

In this case there are a variety of issues here:

  • Suggesting when it should not (e.g., t for the this-qualifier)
  • Suggesting things that don't make sense (e.g., static when inside a let binding)

However it's tricky, since many of these suggestions are valid. For example, match for m makes sense if you're actually going to have a match expression. So it's really a lot of small issues that exacerbate the default setting.

That workaround is just what I needed, thanks!!!

Was this page helpful?
0 / 5 - 0 ratings