Skip to content

Conversation

brettfo
Copy link
Member

@brettfo brettfo commented Mar 25, 2022

For C# add both angle brackets (<>) for generics and parentheses (()) for methods.

For F# only add parentheses (()), but not generic angle brackets because the F# way is to prefer type inference.

The end result when accepting completions in a notebook is to effectively add tab stops ($1, etc.), so e.g.,

Method completion in C#:

  1. The user types: Console.WritL.
  2. From the completion list they see and select WriteLine and commit it with <TAB>.
  3. The editor now looks like: Console.WriteLine(|) (where the pipe is the cursor). The user can type inside the parentheses and when they're done they hit <TAB> again and the cursor is now at the end of the line.

Generic type completion in C#:

  1. The user types: System.Collections.Generic.IEnumerab.
  2. From the completion list they see and select IEnumerable<> and commit it with <TAB>.
  3. The editor now looks like: System.Collections.Generic.IEnumerable<|> (where the pipe is the cursor). The user can type inside the angle brackets and when they're done they hit <TAB> again and the cursor is now at the end of the line.

Generic method completion in C#:

  1. The user types: System.Array.Empt.
  2. From the completion list they see and select Empty<> and commit it with <TAB>.
  3. The editor now looks like: System.Array.Empty<|>() (where the pipe is the cursor). The user can type inside the angle brackets and when they're done they hit <TAB>.
  4. The editor now looks like: System.Array.Empty<int>(|) (where the pipe is the cursor). The user can type inside the parentheses (or not) and when they're done they hit <TAB> again and the cursor is now at the end of the line.

Method completion in F#

Exactly the same as the C# scenario above; parentheses are added for a call to something like System.Console.WriteLine().

Module function completion in F#

Functions defined on a module are commonly curried and parentheses are not preferred. E.g.,

  1. The user types: [1;2;3] |> List.ma.
  2. From the completion list they see and select map and commit it with <TAB>.
  3. The editor now looks like [1;2;3] |> List.map| (where the pipe is the cursor). No parentheses were appended because a function reference is often directly added without parentheses. E.g., [1;2;3] |> List.map someFunction.

Protocol changes

Borrowing the type shape from LSP, only one property, insertTextFormat, was added to the CompletionItem type and it's optional so an older server giving completions to the front end will be unchanged.

@brettfo brettfo requested review from colombod and jonsequitur March 25, 2022 00:20
For C# add both angle brackets (`<>`) for generics and parentheses (`()`) for methods.

For F# only add parentheses (`()`), but not generic angle brackets because the F# way is to prefer type inference.
@brettfo brettfo force-pushed the completion-improvements branch from 78ff0c3 to 255cc63 Compare March 25, 2022 00:26
@brettfo brettfo enabled auto-merge (squash) March 25, 2022 00:32
@brettfo brettfo merged commit d17b93d into dotnet:main Mar 25, 2022
@brettfo brettfo deleted the completion-improvements branch April 6, 2022 23:24
@colombod colombod added the Area-Language Services IntelliSense, LSP, and related label Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Language Services IntelliSense, LSP, and related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants