Skip to content

clang-format won't use .clang-format file on UNC-style network share out of box #2124

Open

Description

@zao

Type: LanguageService

  • OS and Version: Windows 10 1803
  • VS Code Version: 1.23.1
  • C/C++ Extension Version: 0.17.4
  • The .clang-format file will not be used if the project resides on an UNC-style network share, unless the fallback style is forced to "none".
  • This does not occur on drive-letter mounted network shares or local drives.

To Reproduce
Steps to reproduce the behavior:

  1. Prepare a directory with a .clang-format file and some source on a network share like my \\10.0.1.15\zao\code\gggtools.
  2. Open the folder with VS Code.
  3. Open a C++ source file.
  4. Hit the formatting shortcut.
  5. Note that it doesn't use the .clang-format file, instead using the fallback style.
  6. Configure "C_Cpp.clang_format_fallbackStyle": "none" in settings.
  7. Format again.
  8. Note how the .clang-format file is used as intended.

Expected behavior
I expect the formatter to always find and use the .clang-format file in the tree regardless of fallback style.

Activity

  1. sean-mcmanus commented on Jun 12, 2018

    @sean-mcmanus
    Contributor

    This is because we try to search for the .clang-format up the path -- our path iteration code might be buggy for UNC-style paths, although I would expect other scenarios to be buggy as well. That manual checking only gets used if the fall back style is the default of "Visual Studio", so using "none" bypasses it.

  2. sketch34 commented on Sep 27, 2021

    @sketch34

    This occurs for me when using the remote dev feature with WSL2.

    image

    1. Does not use .clang-format file

    My paths are of the form: /home/sketch34/Dev/project/src/subdir/test.cpp

    I cannot make vscode use the .clang-format file located at /home/sketch34/Dev/project with any combination of options. I have tried setting the fallback style to "none". I also tried moving the .clang-format file into the /src directory.

        "C_Cpp.clang_format_fallbackStyle": "",
        "C_Cpp.clang_format_style": "file",
    

    2. Empty fallbackStyle disables clang_format_style

    Additionally if the fallback style is empty "C_Cpp.clang_format_fallbackStyle": "" then the C_Cpp.clang_format_style has no effect.

    E.g. This works and applies the LLVM style:

        "C_Cpp.clang_format_fallbackStyle": "WebKit",
        "C_Cpp.clang_format_style": "LLVM",
    

    This has no effect and will not apply any formatting:

        "C_Cpp.clang_format_fallbackStyle": "",
        "C_Cpp.clang_format_style": "LLVM",
    

    Version: 1.60.1 (user setup)
    Commit: 83bd43bc519d15e50c4272c6cf5c1479df196a4d
    Date: 2021-09-10T17:07:10.714Z
    Electron: 13.1.8
    Chrome: 91.0.4472.164
    Node.js: 14.16.0
    V8: 9.1.269.39-electron.0
    OS: Windows_NT x64 10.0.19042

  3. sean-mcmanus commented on Sep 28, 2021

    @sean-mcmanus
    Contributor

    Jarrod Smith (@sketch34) Your issue is not the same as the original issue (you're not using UNC-style paths). I'll move it to a new issue.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions