From 727c4800d8b9e7a74b4e2a5f20bc942e3462fff3 Mon Sep 17 00:00:00 2001 From: Mark Sujew Date: Wed, 4 Dec 2024 16:43:35 +0100 Subject: [PATCH] Improve error behavior --- .../src/lsp/completion/follow-element-computation.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/langium/src/lsp/completion/follow-element-computation.ts b/packages/langium/src/lsp/completion/follow-element-computation.ts index f595977df..69bb376b1 100644 --- a/packages/langium/src/lsp/completion/follow-element-computation.ts +++ b/packages/langium/src/lsp/completion/follow-element-computation.ts @@ -52,6 +52,10 @@ function findNextFeaturesInternal(options: { next: NextFeature, cardinalities: M const feature = next.feature; if (visited.has(feature)) { return []; + } else if (!ast.isGroup(feature)) { + // Do not the feature to the list if it is a group + // `findFirstFeaturesInternal` will take care of this + visited.add(feature); } let parent: ast.Group | undefined; let item = feature; @@ -130,8 +134,6 @@ function findFirstFeaturesInternal(options: { next: NextFeature, cardinalities: } else { visited.add(feature); } - } - if (ast.isGroup(feature)) { return findNextFeaturesInGroup(next as NextFeature, 0, cardinalities, visited, plus) .map(e => modifyCardinality(e, feature.cardinality, cardinalities)); } else if (ast.isAlternatives(feature) || ast.isUnorderedGroup(feature)) {