================
@@ -3131,20 +3132,25 @@ static void sortCppIncludes(const FormatStyle &Style,
}
result += Includes[Index].Text;
if (Cursor && CursorIndex == Index)
- *Cursor = IncludesBeginOffset + result.size() - CursorToEOLOffset;
+ NewCursor = IncludesBeginOffset + result.size() - CursorToEOLOffset;
CurrentCategory = Includes[Index].Category;
}
- if (Cursor && *Cursor >= IncludesEndOffset)
- *Cursor += result.size() - IncludesBlockSize;
-
// If the #includes are out of order, we generate a single replacement fixing
// the entire range of blocks. Otherwise, no replacement is generated.
if (replaceCRLF(result) == replaceCRLF(std::string(Code.substr(
IncludesBeginOffset, IncludesBlockSize)))) {
return;
}
+ if (Cursor) {
+ if (UINT_MAX != NewCursor) {
+ *Cursor = NewCursor;
+ } else if (*Cursor >= IncludesEndOffset) {
+ *Cursor += result.size() - IncludesBlockSize;
+ }
----------------
HazardyKnusperkeks wrote:
```suggestion
if (NewCursor != UINT_MAX)
*Cursor = NewCursor;
else if (*Cursor >= IncludesEndOffset)
*Cursor += result.size() - IncludesBlockSize;
```
https://github.com/llvm/llvm-project/pull/77456
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits