Skip to content

Added Opening Brace as trigger character for formatAfterKeyStroke - #1042

Open
akshita31 wants to merge 3 commits into
OmniSharp:masterfrom
akshita31:format_keystroke
Open

Added Opening Brace as trigger character for formatAfterKeyStroke#1042
akshita31 wants to merge 3 commits into
OmniSharp:masterfrom
akshita31:format_keystroke

Conversation

@akshita31

@akshita31 akshita31 commented Dec 5, 2017

Copy link
Copy Markdown
Contributor

Issue : dotnet/vscode-csharp#1591

Added { as trigger character for formatting changes request.

Please review : @DustinCampbell @TheRealPiotrP @rchande

@akshita31

Copy link
Copy Markdown
Contributor Author

omnisharp-vscode side : dotnet/vscode-csharp#1906

@DustinCampbell

Copy link
Copy Markdown
Contributor

I'm a little worried about this change. What happens in the following case?

  1. Set "editor.autoClosingBrackets": false in the VS Code settings.
  2. Start with this code;
    class C
    {
        void M1()
        $$
    
        void M2()
        {
        }
    }
  3. Type { at the caret position ($$)

Does the declaration of M2() get indented? If so, this might not be the right approach.

@akshita31

Copy link
Copy Markdown
Contributor Author

ezgif com-video-to-gif

It doesn't indent M2()

@DustinCampbell DustinCampbell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for verifying the behavior

@akshita31

akshita31 commented Dec 5, 2017

Copy link
Copy Markdown
Contributor Author

Just noticed a problem with this change. After the format the caret symbol should appear just before the closing brace so that on hitting enter we have a proper indentation

ezgif com-video-to-gif

@DustinCampbell

Copy link
Copy Markdown
Contributor

Maybe debug and see if it's got the correct span for the format?

@akshita31

akshita31 commented Dec 14, 2017

Copy link
Copy Markdown
Contributor Author

Tried to edit the span on hitting enter (for this particular case) to include three lines - the previous line(opening brace) , the current line and the nextLine (closing brace), but doing that deletes the spaces in the current line.
incorrect_cursor

I think this is related to auto-indent in vscode. Hence I have filed a bug in vscode here

cc @rchande

@filipw filipw added the blocked label Jan 29, 2018
@gabrieldechichi

Copy link
Copy Markdown

Any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants