diff --git a/ports/cpp/source/antlr4-c3/CodeCompletionCore.cpp b/ports/cpp/source/antlr4-c3/CodeCompletionCore.cpp index c2fdc6d..49995c4 100644 --- a/ports/cpp/source/antlr4-c3/CodeCompletionCore.cpp +++ b/ports/cpp/source/antlr4-c3/CodeCompletionCore.cpp @@ -131,6 +131,13 @@ CandidatesCollection CodeCompletionCore::collectCandidates( processRule(atn->ruleToStartState[startRule], 0, callStack, 0, 0, candidates.isCancelled); + for (auto& [_, following] : candidates.tokens) { + auto removed = std::ranges::remove_if(following, [&](size_t token) { + return ignoredTokens.contains(token); + }); + following.erase(std::begin(removed), std::end(removed)); + } + if (debugOptions.showResult) { if (candidates.isCancelled) { std::cout << "*** TIMED OUT ***\n"; diff --git a/ports/cpp/test/expr/ExprTest.cpp b/ports/cpp/test/expr/ExprTest.cpp index db9c022..f0b945d 100644 --- a/ports/cpp/test/expr/ExprTest.cpp +++ b/ports/cpp/test/expr/ExprTest.cpp @@ -98,8 +98,8 @@ TEST(SimpleExpressionParser, TypicalSetup) { auto candidates = completion.collectCandidates(0); EXPECT_THAT(Keys(candidates.tokens), UnorderedElementsAre(ExprLexer::VAR, ExprLexer::LET)); - EXPECT_THAT(candidates.tokens[ExprLexer::VAR], ElementsAre(ExprLexer::ID, ExprLexer::EQUAL)); - EXPECT_THAT(candidates.tokens[ExprLexer::LET], ElementsAre(ExprLexer::ID, ExprLexer::EQUAL)); + EXPECT_THAT(candidates.tokens[ExprLexer::VAR], ElementsAre()); + EXPECT_THAT(candidates.tokens[ExprLexer::LET], ElementsAre()); } { // 2) On the variable name ('c').