[clang] [clang-format] Do not update cursor pos if no includes replacement (PR #77456)
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 22 02:03:17 PST 2024
https://github.com/owenca commented:
`git diff Format.cpp` output:
```
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -3116,6 +3116,7 @@ static void sortCppIncludes(const FormatStyle &Style,
return;
}
+ const auto OldCursor = Cursor ? *Cursor : 0;
std::string result;
for (unsigned Index : Indices) {
if (!result.empty()) {
@@ -3139,6 +3140,8 @@ static void sortCppIncludes(const FormatStyle &Style,
// the entire range of blocks. Otherwise, no replacement is generated.
if (replaceCRLF(result) == replaceCRLF(std::string(Code.substr(
IncludesBeginOffset, IncludesBlockSize)))) {
+ if (Cursor)
+ *Cursor = OldCursor;
return;
}
```
https://github.com/llvm/llvm-project/pull/77456
More information about the cfe-commits
mailing list