microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.52k stars 1.55k forks source link

vcFormat: on-type formatting on Enter should not indent the next existing line #7815

Open Aegel5 opened 3 years ago

Aegel5 commented 3 years ago

Bug type: Language Service

Describe the bug Version: 1.57.1 (user setup) Commit: 507ce72a4466fbb27b715c3722558bb15afa9f48 Date: 2021-06-17T13:28:07.755Z Electron: 12.0.7 Chrome: 89.0.4389.128 Node.js: 14.16.0 V8: 8.9.255.25-electron.0 OS: Windows_NT x64 10.0.19042 C/C++ Extension Version: 1.5.1

Steps to reproduce

  1. Open a.cpp using the settings.json
  2. Set cursor after if (a < 10)
  3. Press Enter
  4. See that before return was inserted 4 spaces.
  5. Try this in VS and see that VS does not insert spaces in that case.

a.cpp

void f(int a) {
    if (a < 10)
    return;
}

settings.json

{
    "editor.formatOnType": true,
    "C_Cpp.formatting": "vcFormat",
}
Colengms commented 3 years ago

Hi @alexzh2 . Thanks for reporting this. To me, the issue appears to be that formatting gets applied to the subsequent line (not the whole block), and should not be. Do you have other reasons for wanting to disable Enter triggering on-type formatting? If not, I can repurpose this issue to track not indenting the subsequent line.

Aegel5 commented 3 years ago

I can repurpose this issue to track not indenting the subsequent line.

Hello @Colengms. Yes, for me 'not indenting the subsequent line' is OK.

Colengms commented 3 years ago

It's looks like this issue was introduced due to the fix for: https://github.com/microsoft/vscode-cpptools/issues/7125