[PATCH] D54881: [clang-format] Prevent Clang-Format from editing leading whitespace on lines outside of the format range

Manuel Klimek via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 11 08:43:21 PDT 2019


klimek added a comment.

In D54881#1462804 <https://reviews.llvm.org/D54881#1462804>, @russellmcc wrote:

> Thanks for the explanation!  I do understand your philosophy on this, and agree with the desired behavior case you brought up where you have put in new braces.
>
> After thinking about this more, the thing I really care about is that clang-format is idempotent with a line filter - i.e., running it twice should always have the same effect as running it once.
>
> So, either this fix, or your proposed fix of fixing all lines until the next correct indentation would meet that idempotence criteria.
>
> However, I think in this particular case I still prefer my fix - to me, line filter is meant to limit the effect of clang-format to just fix a particular change and the fallout from that.  However, if the lines _after_ a change were wrong before, this feels very unrelated to the change that was made - why is now the time to fix these unrelated lines?


I agree and would be happy with the change if it would only change the line-filtered workflow, but this afaict (unless I'm missing something :) will also affect the workflow where the provided range is 0-length range, which has an implicit "format stuff around this" request from the user inside it. I'd be happy with a patch that differentiates these two sides.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54881/new/

https://reviews.llvm.org/D54881





More information about the cfe-commits mailing list