alexkrechik / VSCucumberAutoComplete

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

Optional parts with whitespace are not matched #292

Open vincentdebruijn opened 5 years ago

vincentdebruijn commented 5 years ago

Describe the bug (Probably related to other issues about special characters in steps) The autocomplete does not match when an optional part contains whitespace. So the feature file shows the green squiggly line under the step.

On version 2.14.1

To Reproduce The step:

When the foo hits the bar

matches (no green squiggly line) with the following step definition:

When('the foo(d) hits the bar', () => {});

but does not match (shows green squiggly line) the following step definition:

When('the foo( d) hits the bar', () => {});

(this last step DOES match when the original step is:

When the foo d hits the bar

Expected behavior I would expect the autocomplete to match a step which does not contain an optional part with whitespace.

Note: cucumber does match the step; the test runs fine.

settings.json

{
  "editor.formatOnSave": true,
  "beautify.options": {
    "preserve_newlines": true
  },
  "search.usePCRE2": true,
  "cucumberautocomplete.steps": ["tests/**/*.steps.ts"],
  "cucumberautocomplete.syncfeatures": "tests/**/*.feature",
  "cucumberautocomplete.strictGherkinCompletion": true,
  "cucumberautocomplete.smartSnippets": true,
  "cucumberautocomplete.stepsInvariants": true,
  "cucumberautocomplete.skipDocStringsFormat": true,
  "cucumberautocomplete.formatConfOverride": {
    "And": 3,
    "But": "relative"
  },
  "cucumberautocomplete.onTypeFormat": true,
  "editor.quickSuggestions": {
    "comments": false,
    "strings": true,
    "other": true
  },
  "cucumberautocomplete.gherkinDefinitionPart": "(Given|When|Then)\\("
}
johnknoop commented 4 years ago

+1 for this.

I'm also using optional parts with whitespace a lot. Examples:

When("(the user )clicks the button {string}")

which will match both

When the user clicks the button "Save" And clicks the button "Close"

algoritmus commented 4 years ago

If you need a quick fix, modify your extension code: \server\steps.handler.js: //Optional Text step = step.replace(/\(([a-z]+)\)/g, '($1)?'); to (add \s after z)

//Optional Text step = step.replace(/\(([a-z\s]+)\)/g, '($1)?');

johnknoop commented 3 years ago

Any progress on this?

aroliveira3 commented 3 years ago

Any progress? I'm stucked with this problem too

robertaocanastrao commented 3 years ago

Any update?? I'm facing this issue too :(

aotests commented 3 years ago

+1

I also need to use optional parts because the gramatical rules in portuguese :/ Given("(que eu )aciono a opção {string}")

tbrek commented 2 years ago
Then('I should (still )see {string} on the page', function (text) {
  cy.contains(text).should('be.visible')
})

Same issue here.

vitalets commented 2 days ago

Hi @alexkrechik! This issue is very annoying for us as well. I've created a PR https://github.com/alexkrechik/VSCucumberAutoComplete/pull/509 with the fix proposed in https://github.com/alexkrechik/VSCucumberAutoComplete/issues/292#issuecomment-628604654. Could you have a look, as one parsing test is failing and for me it's difficult to identify how to fix. Thanks in advance!