Skip to content

.clang-format-ignore not being used #13005

Open
@jalanh11640

Description

@jalanh11640

Environment

  • OS and Version: macOS Sequoia 15.2
  • VS Code Version: 1.95.3 (Universal)
  • C/C++ Extension Version: v1.22.11
  • If using SSH remote, specify OS of remote machine: N/A

Bug Summary and Steps to Reproduce

Bug Summary: When using Format Document from the (right click) context menu, the active file is formatted when that file is listed in .clang-format-ignore.

Steps to reproduce:

  1. Create test.cpp in root of project with contents of
#include <iostream>

int main(int argc, char *argv[])
{
  int value = 5;
  int x = 0;

  return 0;
}
  1. Create .clang-format file in root of project with contents of AlignConsecutiveAssignments: true
  2. Create .clang-format-ignore file in the root of the project with the absolute path to test.cpp
  3. Open test.cpp in editor, right click and select Format Document
  4. Notice that file has been updated with the formatting specified in .clang-format

If you run clang-format -i test.cpp in the integrated kernel, the file's format is not updated.

Expected behavior: File should not be formatted

Configuration and Logs

I have no c_cpp_properties.json.  Log diagnostics show the clang-format command as:
/Users/jeff/.vscode/extensions/ms-vscode.cpptools-1.22.11-darwin-arm64/bin/../LLVM/bin/clang-format -style=file -fallback-style=LLVM --Wno-error=unknown -assume-filename=/Users/jeff/Development/clang-format/test.cpp

Other Extensions

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions