diff --git a/CHANGELOG.md b/CHANGELOG.md index a7edaecb..7027522d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,13 @@ ## Improvements: +* Generated regexes are prefixed with a caret (`^`) to ensure they are not interpreted as Cucumber expressions. (#98) + ## Bug fixes: + * Fix: Ambiguous steps reported wehn definition matches via more than one tag (#95) -*Contributors of this release (in alphabetical order):* @clrudolphi + +*Contributors of this release (in alphabetical order):* @304NotModified, @clrudolphi # v2025.1.256 - 2025-03-07 diff --git a/Reqnroll.VisualStudio/Snippets/Fallback/RegexStepDefinitionSkeletonProvider.cs b/Reqnroll.VisualStudio/Snippets/Fallback/RegexStepDefinitionSkeletonProvider.cs index 19979628..4efcde28 100644 --- a/Reqnroll.VisualStudio/Snippets/Fallback/RegexStepDefinitionSkeletonProvider.cs +++ b/Reqnroll.VisualStudio/Snippets/Fallback/RegexStepDefinitionSkeletonProvider.cs @@ -11,7 +11,8 @@ public RegexStepDefinitionSkeletonProvider(ReqnrollProjectTraits projectTraits) protected override string GetExpression(AnalyzedStepText stepText) { - StringBuilder result = new StringBuilder(); + // Prefix regex with ^ to ensure that it's detected as regex instead of a cucumber expression. + StringBuilder result = new StringBuilder("^"); result.Append(EscapeRegex(stepText.TextParts[0])); for (int i = 1; i < stepText.TextParts.Count; i++) diff --git a/Tests/Reqnroll.VisualStudio.Specs/Features/Editor/Commands/DefineStepsCommand.feature b/Tests/Reqnroll.VisualStudio.Specs/Features/Editor/Commands/DefineStepsCommand.feature index 2e3ebe70..6aa5aadd 100644 --- a/Tests/Reqnroll.VisualStudio.Specs/Features/Editor/Commands/DefineStepsCommand.feature +++ b/Tests/Reqnroll.VisualStudio.Specs/Features/Editor/Commands/DefineStepsCommand.feature @@ -125,7 +125,7 @@ Scenario: DefineSteps command abides by reqnroll.json configuration for regex sk When I invoke the "Define Steps" command Then the define steps dialog should be opened with the following step definition skeletons | type | expression | - | Given | the client added (.*) pcs to the basket | + | Given | ^the client added (.*) pcs to the basket | Scenario: DefineSteps command properly escapes empty brackets when using Cucumber expressions Given there is a Reqnroll project scope @@ -161,5 +161,5 @@ Scenario: DefineSteps command properly escapes empty brackets when using Regex e When I invoke the "Define Steps" command Then the define steps dialog should be opened with the following step definition skeletons | type | expression | - | When | I use \\(parenthesis\), \\{curly braces}, \\\ backslash, and/or \\. period | + | When | ^I use \\(parenthesis\), \\{curly braces}, \\\ backslash, and/or \\. period |