Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional parts with whitespace are not matched #292

Open
vincentdebruijn opened this issue Aug 12, 2019 · 8 comments · May be fixed by #509
Open

Optional parts with whitespace are not matched #292

vincentdebruijn opened this issue Aug 12, 2019 · 8 comments · May be fixed by #509
Milestone

Comments

@vincentdebruijn
Copy link

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
Copy link

+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"

@alexkrechik alexkrechik added this to the 2.16.0 milestone Jan 9, 2020
@algoritmus
Copy link

algoritmus commented May 14, 2020

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)?');

@alexkrechik alexkrechik modified the milestones: 2.16.0, 2.15.0 Jun 24, 2020
@johnknoop
Copy link

Any progress on this?

@aroliveira3
Copy link

Any progress? I'm stucked with this problem too

@robertaocanastrao
Copy link

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

@aotests
Copy link

aotests commented Jul 8, 2021

+1

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

@tbrek
Copy link

tbrek commented Oct 28, 2021

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

Same issue here.

@alexkrechik alexkrechik modified the milestones: 2.15.0, 2.16.0 Jul 3, 2022
@alexkrechik alexkrechik modified the milestones: 3.0.0, 3.1.0 May 16, 2024
vitalets added a commit to vitalets/VSCucumberAutoComplete that referenced this issue Oct 22, 2024
@vitalets vitalets linked a pull request Oct 22, 2024 that will close this issue
@vitalets
Copy link

Hi @alexkrechik!
This issue is very annoying for us as well.
I've created a PR #509 with the fix proposed in #292 (comment).
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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants