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

Syntax coloring of non-example parameters in scenario outline step not working when example parameter used in the same step #25

Open
jrbye opened this issue Apr 5, 2019 · 2 comments

Comments

@jrbye
Copy link

jrbye commented Apr 5, 2019

When using Scenario Outline and using a parameter from the Examples table in a step any additional parameters used in that same step do not have Syntax Coloring regardless of the position of the parameters in the step.

The following example shows working highlighting of a parameter in line 1 and the Example parameter highlighted in green and an additional parameter 'Duration' left white.
image

Here is an example where the white parameter is first. It exhibits the same behavior.
image

Any steps after the affected steps that don't contain example parameters highlight correctly.

@jrbye jrbye changed the title Syntax coloring of non-example parameters in scenario outline not working when example parameter used in the line Syntax coloring of non-example parameters in scenario outline not working when example parameter used in the step Apr 5, 2019
@jrbye jrbye changed the title Syntax coloring of non-example parameters in scenario outline not working when example parameter used in the step Syntax coloring of non-example parameters in scenario outline step not working when example parameter used in the same step Apr 5, 2019
@gasparnagy
Copy link
Contributor

This behavior is by design, but maybe not the best one.
The problem is that in case of an outline step, the location of the outline placeholders (<duration>) and the location of the step parameters matched from the regex might be misaligned. Therefore the current behavior is:

  • Color outline placeholders only if there are outline placeholders
  • Color step parameters if there are no placeholders

A tricky example would be the following (this example does not make sense, of course, but it is hard to detect):

Let's consider this step definition

[When(@"this is a '([a-z ]*)' step")]
public void WhenFoo(string param)
{ }

And the following scenario outline

Scenario Outline: Parameter mix
  When this is a '<param1>' step        # step A
  When this is <param2> step            # step B
  When this is <param3> tricky' step    # step C
Examples:
  | param1 | param2     | param3  |
  | tricky | a 'tricky' | a 'very |

In this example

  • Step A: the outline placeholders and the step parameters are aligned (like in your example), we could be color <param1> with both italic (placeholder) and brown (parameter)
  • Step B: the placeholder contains the parameter entirely. Probably in this case we should only color it as placeholder
  • Step C: The placeholder and the parameter overlaps. I have no idea what coloring would make sense. Maybe color <param3> as placeholder and tricky as step parameter?

It is also a problem to detect the situation, because the regex of the step definition might not even match to the step line with the placeholder. E.g. in my case the regex allows letters and spaces ([a-z ]*) that does not match to <param1> (because of the angle brackets).

@jrbye
Copy link
Author

jrbye commented Apr 12, 2019

I see. Since the outline parameter is surrounded by <> would you be able to do the coloring of all of the parameters based on the placeholder (column name in the Examples table) before substituting the value in there? The column names shouldn't contain any special characters and they should be discernible based on the <>. Then your match you are using for current non-outline parameters would work for the remaining parameter right?

I know that I don't know anything and I am oversimplifying lots of stuff so if this doesn't make any sense please let me know. I just wanted to share that incase it sparked an idea on your side.

Thanks for all of the work on the extension. It is working very well for me so far.

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

No branches or pull requests

2 participants