[PATCH] D131154: FoldingRanges: Handle LineFoldingsOnly clients.
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 29 06:19:11 PDT 2022
kadircet added inline comments.
================
Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:254
+ // Remove the ending sentinal "*/" from the block comment range.
+ if (Code.substr(EndOffset(*LastComment) - 2, 2) == "*/") {
+ End.character -= 2;
----------------
this is actually not true, we might have `// foo */`, so we need to check if it has `/*` in the beginning again.
also can we have it in an explicit variable instead `bool IsBlockComment`
================
Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:259
+ // Always show last line of a block comment.
+ if (Code.substr(StartOffset(*LastComment), 2) == "/*" &&
+ StartPosition(*LastComment).line != EndPosition(*LastComment).line) {
----------------
so it actually gets pretty annoying with mixture of block and line comments back to back, but also with multiple block comments back to back, e.g:
```
/* foo
* bar*/
```
vs
```
/* foo */
/* bar */
```
vs
```
// foo
/* bar */
```
which is rare, so i don't think it's worth handling. but at least to make it consistent, rather than checking for the start/end lines of the lastcomment, we should actually be looking at the whole range and whether we've started the range with a blockcomment. (sorry for noticing it too late)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131154/new/
https://reviews.llvm.org/D131154
More information about the cfe-commits
mailing list