diff options
-rw-r--r-- | clangd/Selection.cpp | 3 | ||||
-rw-r--r-- | unittests/clangd/SelectionTests.cpp | 5 |
2 files changed, 6 insertions, 2 deletions
diff --git a/clangd/Selection.cpp b/clangd/Selection.cpp index d1ea30e7..233a4369 100644 --- a/clangd/Selection.cpp +++ b/clangd/Selection.cpp @@ -198,11 +198,10 @@ private: auto E = SM.getDecomposedLoc(R.getEnd()); if (B.first != SelFile || E.first != SelFile) continue; - assert(R.isTokenRange()); // Try to cover up to the next token, spaces between children don't count. if (auto Tok = Lexer::findNextToken(R.getEnd(), SM, LangOpts)) E.second = SM.getFileOffset(Tok->getLocation()); - else + else if (R.isTokenRange()) E.second += Lexer::MeasureTokenLength(R.getEnd(), SM, LangOpts); ChildRanges.push_back({B.second, E.second}); } diff --git a/unittests/clangd/SelectionTests.cpp b/unittests/clangd/SelectionTests.cpp index 2322a0e6..2d962712 100644 --- a/unittests/clangd/SelectionTests.cpp +++ b/unittests/clangd/SelectionTests.cpp @@ -232,6 +232,11 @@ TEST(SelectionTest, Selected) { }]]]] } )cpp", + R"cpp( + template <class T> + struct unique_ptr {}; + void foo(^$C[[unique_ptr<unique_ptr<$C[[int]]>>]]^ a) {} + )cpp", }; for (const char *C : Cases) { Annotations Test(C); |