[clang-tools-extra] [clangd] Implement simple folding for preprocessor branches (PR #140959)
Nathan Ridge via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 23 05:33:49 PDT 2025
================
@@ -220,6 +220,24 @@ getFoldingRanges(const std::string &Code, bool LineFoldingOnly) {
auto EndPosition = [&](const Token &T) {
return offsetToPosition(Code, EndOffset(T));
};
+
+ // Preprocessor directives
+ auto PPRanges = pairDirectiveRanges(DirectiveStructure, OrigStream);
----------------
HighCommander4 wrote:
Could you add a testcase that has a nested conditional in both branches of an outer conditional, and checks that both nested conditionals get a folding range? (It would be easy to get this wrong by passing `ParseableStream` rather than `OrigStream` here, which would have the effect of only processing the branch of the outer conditional which we heuristically decided to treat as active.)
https://github.com/llvm/llvm-project/pull/140959
More information about the cfe-commits
mailing list