alexkrechik / VSCucumberAutoComplete

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

Relative Indentation both ways #437

Closed pf-lkobbe closed 2 years ago

pf-lkobbe commented 2 years ago

Fixed issues #343 and #378, which describe problems with relative indentation. According to the README, the 'relative' keyword should use the same indentation as the previous line. However, the code actually looks up lines after the current line to determine the relative indentation. The PR adds the 'relativeUp' keyword to use indentation from previous lines. It also fixes an issue with multiple Rules in a single feature file, which resulted in wrong indentation for all but the first rule.

  "cucumberautocomplete.formatConfOverride": {
    "And": 3,
    "But": "relativeUp",
    "@": "relative"
  }

Result before this PR (notice the But and the last @tag not being indented correctly):

@tag
Feature: Some Feature

  @tag
  Rule: Some rule
    Some description

    @tag
    Scenario:
      Some description
      Given Start to type your Given step here
        And something else
      But something different
      When Start to type your When step here
      Then Start to type your Then step here

    @tag
  Rule: Some rule
    Some description

Result with this PR:

@tag
Feature: Some Feature

  @tag
  Rule: Some rule
    Some description

    @tag
    Scenario:
      Some description
      Given Start to type your Given step here
        And something else
        But something different
      When Start to type your When step here
      Then Start to type your Then step here

  @tag
  Rule: Some rule
    Some description