alexkrechik / VSCucumberAutoComplete

Cucumber (Gherkin) Full Support Extension for VSCode
https://marketplace.visualstudio.com/items?itemName=alexkrechik.cucumberautocomplete
MIT License
331 stars 79 forks source link

No way to disable formatting of valid DOCSTRING placement #457

Open KelseyDH opened 1 year ago

KelseyDH commented 1 year ago

Describe the bug This plugin does not respect docstring placement.

To Reproduce Steps to reproduce the behavior:

  1. Install the plugin with cucumberautocomplete.skipDocStringsFormat set to true.
  2. Create this Gherkin file w/ with plugin installed:
Feature:  Phrases
  Scenario: 500 years later, people started using chickens for sacred events, sometimes eating them.
    Given the text "500 years later, people started using chickens for sacred events, sometimes eating them."
    Then the api returns:
"""
    500 years later,
people
started
    using
        chickens
        for sacred events,
        sometimes eating
            them.
"""
  1. click save or otherwise trigger the plugin, and the text will format the DOCSTRING rightwards, breaking the test:
Feature:  Phrases
  Scenario: 500 years later, people started using chickens for sacred events, sometimes eating them.
    Given the text "500 years later, people started using chickens for sacred events, sometimes eating them."
    Then the api returns:
      """
    500 years later,
people
started
    using
        chickens
        for sacred events,
        sometimes eating
            them.
      """

Expected behavior The Gherkin syntax spec clearly states that:

Indentation of the opening """ is unimportant, although common practice is two spaces in from the enclosing step. The indentation inside the triple quotes, however, is significant. Each line of the Doc String will be dedented according to the opening """. Indentation beyond the column of the opening """ will therefore be preserved.

In my case I cannot write functional tests with the VSCode plugin enabled, as it overrides my placement of DOCSTRINGSs fully dedented. The behaviour I want is for Gherkin highlighting to exist without it touching DOCSTRING placement at all. As our team copies and pastes from these indented texts often, we have a valid reason to want the DOCSTRING fully dedented and placed leftwards for each test. Per the syntax spec, this is valid Gherkin.

Cucumberautocomplete part of VSCode settings:

{
  "cucumberautocomplete.steps": [
      "features/step_definitions/*.js",
      "node_modules/@revjet/csp-qa/src/steps/*.js"
  ],
  "cucumberautocomplete.skipDocStringsFormat": true,
  "cucumberautocomplete.syncfeatures": "features/*.feature",
  "cucumberautocomplete.strictGherkinCompletion": true,
  "cucumberautocomplete.smartSnippets": true,
  "cucumberautocomplete.stepsInvariants": true,
  "cucumberautocomplete.onTypeFormat": false,
  "cucumberautocomplete.formatConfOverride": {
      "And": 0,
  }
}
ymouhat commented 2 months ago

Hi @alexkrechik I think have a similar issue using the following step definition

the message containing text is 
            """
            message 1
            next message 2
               next message with indentation
            """

when I press save the doctstring removes the space at the begining

the message containing text is 
            """
            message 1
            next message 2
            next message with indentation
            """

is there a way to avoid this behavior, as it makes the step definition to fail. THank you in advance