When clang-format is set to always use tabs (with tab width 4), when asked to format line 3 (using the -lines=3:3 flag):
int f() { int a; foobar(); int b; }
We would expect clang-format to not modify the leading whitespace on line 4. However, it does - see the new test. This is because the whitespace manager is called to replace the whitespace before the first token of line 4. This is necessary to edit the number of new lines before line 4, and to edit the trailing whitespace on line 3. I've added a flag to replaceWhitespace that allows it to not edit the leading whitespace, and only edit the whitespace up to the last newline.
We ran into this when trying to integrate clang-format with a line filter into our CI to ensure no new formatting diffs were introduced in a patch. With the buggy behavior without this patch, the number of affected lines grew each time clang-format was run with a line filter, so running clang-format locally on the changed lines was not enough to ensure that CI would pass.
is this a SourceRange? Please spell out the type, as there are different kind of ranges.