Change snippet in class member completions #46593
Closed
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.
Partially fixes #46568.
Whenever completions offer a method snippet, the parameter names and types, and the return type are snippet placeholders, as described in #46370. And, if the method has a body, there is a tabstop in the empty body.
We are assuming that, in most cases, the person using the method snippet won't want to change the method signature, and will instead just want to fill in the body with the implementation of the method.
For that reason, the tabstop in the body is the first one, so when the method snippet is inserted, the cursor is in the body, like so:
This PR adds a second tabstop, namely
$0
, right next to the first tabstop, in the body of the method.$0
is special, in that it is the last tabstop. This means that the following flow is possible:after pressing tab a few times, navigating through the method signature:
after pressing tab one last time, after going through (and possibly editing) the parameters and return type: