alexkrechik / VSCucumberAutoComplete

Cucumber (Gherkin) Full Support Extension for VSCode
https://marketplace.visualstudio.com/items?itemName=alexkrechik.cucumberautocomplete
MIT License
332 stars 82 forks source link

(C++) Unable to (properly) match rawstring literals #473

Open daantimmer opened 1 year ago

daantimmer commented 1 year ago

Describe the bug C++11 introduced raw string literals. Which are the preferd method of writing regular expressions in C++. Raw string literals look like: const char* str = R"(this is a raw string literal)";. Raw string literals start with R"( and end with )". Given the current tools provided by VSCucumberAutoComplete it is impossible to properly match raw string literal steps:

// steps/step_implementation_file.cpp
GIVEN(R"(there is a step that is a raw string literal)")
{}

To Reproduce Steps to reproduce the behavior:

  1. create a file in steps/stepimpl.cpp
  2. add contents shown above
  3. create a feature file containing a scenario with the above step
  4. observe the match to be: (there is a step that is a raw string literal)

Expected behavior VSCucumberAutoComplete treats the above GIVEN step as capturing the whole string, which is incorrect. Example: image

Screenshots See Expected Behaviour

Cucumberautocomplete part of VSCode settings:

{
    "cucumberautocomplete.steps": [
        "steps/*.cpp"
    ],
    "cucumberautocomplete.gherkinDefinitionPart": "(GIVEN|WHEN|THEN|STEP)\\(R"
}

Step definition: See above

Gherkin step line See above

daantimmer commented 1 year ago

It is possible to workaround the issue using:

{
    "cucumberautocomplete.customParameters": [
        {
            "parameter": "\"(",
            "value": "\""
        },
        {
            "parameter": ")\"",
            "value": "\""
        }
    ]
}

This does mean every occurance of "( and )" within a regular expression would be replaced by ".