Skip to content

Expand Edit.SmartBreakLine handling to more scenarios #48857

@sharwell

Description

@sharwell

🔗 Related to #18065

Currently Edit.SmartBreakLine (Shift+Enter) is not particularly useful. It should be updated to have the following behavior:

  1. (Addresses Shift-Enter commits completion, but doesn't complete the current statement #18065) If completion is active, the editor commits the current completion and, if the item is a method name where a method group expression is not allowed, automatically inserts the ( and ).

  2. If the current caret context is a parent statement that can have a block child (e.g. the span i[|f (condition)|]), the command inserts a new set of braces as the child and places the caret within those braces:

    if (condition)
    {
        $$
    }
    
  3. (Addresses AB#1058964) If the current caret context is a member header which can have braces (e.g. v[|oid Method()|]), the command inserts the braces and places the caret within:

    void Method()
    {
        $$
    }
    
  4. If the current caret context is an expression statement already terminated by a ;, the editor moves to the end of the existing ; and behaves as though Enter was pressed.

  5. If the current caret context is in an expression statement not already terminated by ;, the editor behaves as though ;, Enter was pressed.

  6. (Specifically per Object Intellisense Completion for Init-Only Classes #46297) If the current expression is an object creation expression:

    • If the objection creation expression does not already have braces for an object or collection initializer, the braces are added and the caret is placed within them
    • If the object creation expression already has braces for an object or collection initializer, the editor first removes the braces if they are empty and then treats the command the same way it does for other expression statements.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Complete

Relationships

None yet

Development

No branches or pull requests

Issue actions