add completion item snippet mode #1947
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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#:
Console.WritL
.WriteLine
and commit it with<TAB>
.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#:
System.Collections.Generic.IEnumerab
.IEnumerable<>
and commit it with<TAB>
.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#:
System.Array.Empt
.Empty<>
and commit it with<TAB>
.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>
.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;2;3] |> List.ma
.map
and commit it with<TAB>
.[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 theCompletionItem
type and it's optional so an older server giving completions to the front end will be unchanged.