vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Autocompletion should suggest patterns associated with the specified context/state only

Open The-BDD-Coach opened this issue 2 years ago • 7 comments

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

When I type 'Given...', the autocompletion suggestions include 'When' and 'Then' statements; those aren't valid if the first word in the line is 'Given'. Similarly when I begin a 'When' or 'Then' statement, the autocompletion suggestions aren't filtered to include only 'When' or 'Then' steps; they include everything that appears to be a textual match.

Offering too many suggestions, including suggestions that aren't valid in the current context, clutters the UI and makes it more difficult for the user to find the suggestions that are actually useful. Novice users could also be misled into writing invalid Gherkin.

✨ What's your proposed solution?

Modify the autocompletion logic so that it:

  1. Maintains state - does this 'And' statement follow a 'Given', a 'When', or a 'Then'? (The first word in the line being 'Given', 'When', or 'Then' is the simplest case of this.)
  2. Sorts the autocompletion suggestions into three lists - Given, Whens, and Thens.
  3. Searches only the state-appropriate list for autocompletion suggestions.

The-BDD-Coach avatar Dec 01 '22 17:12 The-BDD-Coach

It looks like the @Then @And annotation is not recognised as a valid step definition by the plugin, despite it being valid at execution time.

jm-paulin avatar Apr 08 '24 10:04 jm-paulin

@jm-paulin, step definitions not being recognized is a different issue; there is a lengthy discussion of it in #120. Kieran Ryan has listed some of the possible causes in a lengthy post there; some of those you can fix by changing your step definitions, but some you can't.

The-BDD-Coach avatar Apr 08 '24 14:04 The-BDD-Coach

Thanks for raising @jm-paulin and cheers @The-BDD-Coach for pointing to some of the challenges - thankfully a small portion of these issues will be resolved in a coming release.

@jm-paulin, as this would be separate from @The-BDD-Coach's feature request, would you be able to raise a bug report on this project with as much detail as possible and a minimum reproducible example (e.g. step definition, feature file, path where files are stored, relevant VSCode settings, language, framework, etc.). Based on that we can determine where this issue belongs and whether a fix is required. However, language support issues typically relate to the Cucumber Language Service.

kieran-ryan avatar Apr 08 '24 17:04 kieran-ryan

I could create an issue @kieran-ryan but I think that would be a duplicate of #147, closed 4 months ago.

I personally think #147 is a valid issue. @And annotated steps definition should be handled/seen by the vscode plugin, Currently they are not and that is a bit of a rewrite when moving from IntelliJ to VSCode.

jm-paulin avatar Apr 09 '24 08:04 jm-paulin

@jm-paulin @And steps are at least sometimes recognized; I am looking at one right now that is recognized. If you have an example of an @And step not being recognized when the underlying @Given or @Then is recognized, that is worth looking into. If it isn't being recognized and the reason isn't any of the ones that Kieran listed in #120 then it is certainly worth writing up as a separate issue.

If you write it up as a separate issue please show the complete source code of the step definition; as Kieran has mentioned, all of these issues are related to the language service, so the exact text of your step definition is critical.

The-BDD-Coach avatar Apr 09 '24 12:04 The-BDD-Coach

If you write it up as a separate issue please show the complete source code of the step definition; as Kieran has mentioned, all of these issues are related to the language service, so the exact text of your step definition is critical.

Created #225.

jm-paulin avatar Apr 11 '24 10:04 jm-paulin

By using v1.10 with Typescript, I see that steps are ordered by statement as:

  1. Given, 2.When, 3. Then

According to proposed solution, this version is on "level 2" solution. Level 3 does not work:

Searches only the state-appropriate list for autocompletion suggestions.

Meaning autosuggestion suggests only Given steps when line start with Given. Same with When and Then.

Is there any update on this issue ?

Lokymil avatar Sep 17 '24 13:09 Lokymil