Skip to content

feat: editor tokens for the names of Feature, Rule, Scenario keywords #249

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ant0x64
Copy link
Contributor

@ant0x64 ant0x64 commented May 19, 2025

Fixes #248

This feature introduces new token classifications for the names of Feature, Rule and Scenario blocks in Cucumber feature files:

  • Feature: keyword is now tokenized as namespace:cucumber
  • Rule: keyword is now tokenized as class:cucumber
  • Scenario: keyword is now tokenized as function:cucumber

🏷️ What kind of change is this?

  • ⚡ New feature (non-breaking change which adds new behaviour)

@luke-hill
Copy link
Contributor

@michaelboyles can you review this?

@michaelboyles
Copy link
Contributor

Seems like a hack really. 'Scenario' is not semantically a function and 'Rule' is not semantically a class. You could make the argument that Feature is a namespace of sorts, I guess.

You're basically assigning any otherwise-unused token type, just so it's unique from the others. The root issue that is monaco doesn't let you style distinct keywords with different styles.

I think there are 3 problems with this PR

  1. it alters existing theming behaviour for other users that they don't necessarily want

  2. the relationship between a keyword and its semantic token type is now less clear, because some of them are just arbitrary. In practical terms, it's harder to style correctly, because how do I know that "Scenario" = "function" without looking at this code?

  3. there may more relevant uses for these token types in the future, and abusing them now may restrict us from using them in the future

@ant0x64
Copy link
Contributor Author

ant0x64 commented May 21, 2025

@luke-hill, my mistake, fixed tests.

@ant0x64
Copy link
Contributor Author

ant0x64 commented May 21, 2025

@michaelboyles,

I agree that mapping Feature, Rule, and Scenario to namespace, class, and function isn't semantically perfect. However, from the available token types, these seemed like the most appropriate fit.

I also considered leaving Feature as keyword and assigning Rule as a namespace instead, but I felt this was ultimately a subjective choice that could be adjusted based on consensus.

"In practical terms, it's harder to style correctly, because how do I know that 'Scenario' = 'function' without looking at this code?"

As someone new to this package, I’d appreciate guidance on how this mapping is typically surfaced. Personally, I’ve been using VSCode’s built-in Editor Token Inspection Tool to identify token types for styling. Is there a more maintainable or standard approach to documenting or discovering these token mappings?

I understand the concern about future token use conflicts and theming side effects. I’m very open to alternative suggestions or a better strategy if there’s a preferred path forward

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

Successfully merging this pull request may close these issues.

Editor token for Feature, Rule and Scenario keywords
3 participants