microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The LineEnding setting in .clang-format has no effect within VS Code

haferburg opened this issue · comments

Environment

  • OS and Version: Ubuntu 22.04 LTS
  • VS Code Version: 1.89
  • C/C++ Extension Version: v1.20.5

Bug Summary and Steps to Reproduce

Create a .cpp file with LF line endings.
Configure a .clang-format file with

LineEnding: CRLF

The format the document.

Expected: The line endings should have been converted to CRLF.

Actual: The line endings stay at LF.

Configuration and Logs

not necessary

Other Extensions

No response

Additional context

No response

When I invoke clang-format with the same command-line plus -i to edit the file in place, it works as expected and the line endings are converted to CRLF. So this behavior is specific to how clang-format is integrated in VS Code.

Please let me know if you need additional information.

Thank you for letting us know about this issue, the current workaround would be to use VS Code's internal support for changing line endings.

  1. There is a setting you can toggle to choose a specific line ending you want to use in future files
    image

  2. There is a command you can access in the editor status bar that will change all of the line endings in a file from LF to CRLF for any active file. You can find this icon in the bottom right of your editor:
    Icon
    image
    Command
    image