Skip to content

clang-format ignores un-ignored paths in .clang-format-ignore with same prefix #13696

Open
@tdscheper

Description

@tdscheper

Environment

  • OS and Version: macOS Sequoia 15.5
  • VS Code Version: 1.101.0-insider
  • C/C++ Extension Version: 1.3.1

Bug Summary and Steps to Reproduce

Given the following folder structure:

.
├── .clang-format
├── .clang-format-ignore
├── .vscode
│   ├── c_cpp_properties.json
│   └── settings.json
├── foo
│   └── foo.h
└── foo_tests
    └── test_foo.c

And this .clang-format-ignore:

*
!foo/*
!foo_tests/*

Formatting foo/foo.h and foo_tests/test_foo.h via the extension does nothing.

When .clang-format-ignore is instead:

*
!foo/*

Formatting foo/foo.h formats as expected, and foo_tests/test_foo.h does not get formatted, also as expected.

When !foo/* is not there and !foo_tests/* is there, expected behavior occurs also.

With the full .clang-format-ignore and running the clang-format packaged in the extension like this:

~/.vscode-insiders/extensions/ms-vscode.cpptools-1.25.3-darwin-arm64/LLVM/bin/clang-format --style=file -i foo/foo.h

foo/foo.h gets formatted as expected. So, I'd expect this to be an issue with the extension, not clang-format.

Configuration and Logs

-------- Diagnostics - 6/12/2025, 10:25:54 PM
Version: 1.25.3
Current Configuration:
{
    "name": "Mac",
    "includePath": [
        "/Users/tdscheper/dev/repo/sandboxes/C/foo"
    ],
    "defines": [],
    "cStandard": "c17",
    "cppStandard": "c++14",
    "intelliSenseMode": "macos-clang-arm64",
    "compilerPath": "/usr/bin/gcc",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "recursiveIncludesReduceIsExplicit": false,
    "recursiveIncludesPriorityIsExplicit": false,
    "recursiveIncludesOrderIsExplicit": false,
    "compilerPathInCppPropertiesJson": "/usr/bin/gcc",
    "mergeConfigurations": false,
    "recursiveIncludes": {},
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Modified Settings:
{
    "C_Cpp.default.compilerPath": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {
        ".arxml": "xml",
        ".clang-format": "yaml",
        ".clang-format-ignore": "ignore"
    },
    "filesExclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/.DS_Store": true,
        "**/Thumbs.db": true,
        "**/__pycache__": true,
        "**/.ruff_cache": true,
        "**/.mypy_cache": true,
        "**/.pytest_cache": true
    },
    "filesAutoSaveAfterDelay": false,
    "editorInlayHintsEnabled": true,
    "editorParameterHintsEnabled": true,
    "searchExclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/*.code-search": true
    },
    "workbenchSettingsEditor": "ui"
}
cpptools version (native): 1.25.3.0
Current database path: /Users/tdscheper/Library/Caches/vscode-cpptools/e82bc75c15d3363dec518c71b74031cf/.browse.VC.db
Translation Unit Mappings:
[ /Users/tdscheper/dev/repo/sandboxes/C/foo_tests/test_foo.c - source TU]:
    /Users/tdscheper/dev/repo/sandboxes/C/foo/foo.h
Translation Unit Configurations:
[ /Users/tdscheper/dev/repo/sandboxes/C/foo_tests/test_foo.c ]
    Process ID: 6458
    Memory Usage: 32 MB
    Compiler Path: /usr/bin/gcc
    Include paths:
        include: /Users/tdscheper/dev/repo/sandboxes/C/foo
        system include: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include
        system include: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
        system include: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
        system framework search path (default): /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks
    Standard Version: c17
    IntelliSense Mode: macos-clang-arm64
    Other Flags:
        --clang
        --clang_version=170006
Total Memory Usage: 32 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 9836
Number of files parsed: 232

Other Extensions

No response

Additional context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions