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

Highlight optionals in Gherkin steps #57

Open
aslakhellesoy opened this issue May 26, 2022 · 0 comments
Open

Highlight optionals in Gherkin steps #57

aslakhellesoy opened this issue May 26, 2022 · 0 comments
Labels
language agnostic ⚡ enhancement Request for new functionality

Comments

@aslakhellesoy
Copy link
Contributor

🤔 What's the problem you're trying to solve?

When a gherkin step is syntax highlighted I want to see the optionals in a different colour. Example:

Cucumber Expression: Joe went to( the) hospital
Gherkin step       : Joe went to the hospital
                                ====

The the should be highlighted in a different colour to give the user a hint that this text is optional and can be removed.
The reason for this is the fix in #56 - some optionals cannot be omitted in autocomplete.

Since the autocomplete suggestion cannot convey information that the optional is really optional, doing this via syntax highlighting seems a good idea.

✨ What's your proposed solution?

Change CucumberExpression.match(string) to return not only matched arguments, but also matched optionals.
This can be achieved by changing TreeRegexp to use named capturing capture groups instead of non-capturing groups for optionals. This is supported by RegExp in Java, JavaScript, Ruby, Go, .NET and Python. In order to distinguish them from other named capture groups, we could use a special prefix like <cucumber-expression-optional-{n}>.

⛏ Have you considered any alternatives or workarounds?

Not highlighting optionals at all. This would mean users never get a hint about optionals.

@aslakhellesoy aslakhellesoy changed the title Re Highlight optionals in Gherkin steps May 26, 2022
@kieran-ryan kieran-ryan added the ⚡ enhancement Request for new functionality label Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language agnostic ⚡ enhancement Request for new functionality
Projects
None yet
Development

No branches or pull requests

2 participants