When sorting #includes, #include directives that have the same text will be deduplicated when sorting #includes, and only the first #include in the duplicate #includes remains. If the Cursor is provided and put on a deleted #include, it will be put on the remaining #include in the duplicate #includes.
Details
Diff Detail
Event Timeline
| lib/Format/Format.cpp | ||
|---|---|---|
| 1242 | This needs a comment on what it is actually doing (including what the intended behavior is). And that comment should also go into the patch description. Also, it might be a good idea to pull this out into a function. | |
| include/clang/Format/Format.h | ||
|---|---|---|
| 551 | Actually, how about we just do this unconditionally? I think people will always want it. | |
| include/clang/Format/Format.h | ||
|---|---|---|
| 551 | Sounds good to me. I'll get rid of the option then. | |
| lib/Format/Format.cpp | ||
|---|---|---|
| 1224 | First off, make this return a pair<unsigned, unsigned> with the two values. And then the comment needs to be more precise: // Returns a pair (Index, OffsetToEOL) describing the position of the cursor // before sorting/deduplicating. Index is the index of the include under the cursor // in the original set of includes. If this include has duplicates, it is the index of // the first of the duplicates as the others are going to be removed. OffsetToEOL // Describes the cursor's position relative to the end of its current line. | |
| 1228 | Fix indent while here. | |
| 1294–1300 | This can also be calculated upfront with: Includes.back().Offset + Includes.back().Text.size() - Includes.front().Offset And maybe you can pull some of those out into variables as they are also used in the very first line of this function. | |
Actually, how about we just do this unconditionally? I think people will always want it.