[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


================
@@ -3134,20 +3135,24 @@ static void sortCppIncludes(const FormatStyle &Style,
     }
     result += Includes[Index].Text;
     if (Cursor && CursorIndex == Index)
-      *Cursor = IncludesBeginOffset + result.size() - CursorToEOLOffset;
+      NewCursor = IncludesBeginOffset + result.size() - CursorToEOLOffset;
----------------
owenca wrote:

```suggestion
      *Cursor = IncludesBeginOffset + result.size() - CursorToEOLOffset;
```
i.e. undo the change.

https://github.com/llvm/llvm-project/pull/77456


More information about the cfe-commits mailing list