Skip to content

clang-format rejects formatting with -length=0 #146036

Open
@kadircet

Description

@kadircet

starting with 1fae591 we reject -length=0. despite the behavior not being specified for such "point" ranges, formatting library and its users (clang-format, clangd, clang-tidy, ...) accepted those, and there are also some unittests that rely on this.

In the wild there are also some editor integrations, most notably VSCode, that can request for formatting of ranges with 0 length (e.g. after user deleted some code, or for empty lines).

Expected behavior in such a scenario is hard to define, the most obvious is to not format anything, but that isn't the existing behavior (I am not sure if that's incidental or deliberate), but clang-format tool erroring-out in such cases now is resulting in regressions for those workflows. Moreover it's also creating divergence with rest of the applications, leaking the details of the specific formatter being used into the higher level applications.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions