michaelklishin / cucumber.el

Emacs mode for editing Cucumber plain text stories
None!
253 stars 90 forks source link

Indentation of "nested" steps #56

Closed fhars closed 10 years ago

fhars commented 10 years ago

This is the actual result of letting feature-mode indent a feature:

Feature: Indentation

  Scenario: Editing a feature file
Given we are in feature-mode
When I press tab
Then code is indented correctly

I'd expect the Given ... When .. Then to be indented on step more than the Scenario.

michaelklishin commented 10 years ago

Do you expect them to be indented after you indent the Scenario line? This may be quite difficult to implement.

aykutyaman commented 10 years ago

It's would be really nice to have.

jimeh commented 10 years ago

I'm have a couple of similar indentation issues. For example if I take the example from Cucumber's wiki:

Feature: Search courses
  Courses should be searchable by topic
  Search results should provide the course code

  Scenario: Search by topic
    Given there are 240 courses which do not have the topic "biology"
    And there are 2 courses, A001 and B205, that each have "biology" as one of the topics
    When I search for "biology"
    Then I should see the following courses:
      | Course code |
      | A001        |
      | B205        |

If I place the cursor at the end of the When I search for "biology" line and press return, the new line is created without any indentation, and pressing TAB does not perform any indentation. Additionally pressing TAB on any existing and already indented lines, removes all indentation from the line, suggesting that it thinks the correct indentation level is 0.

As far as I recall, indentation used to work normally till a few months ago (2-6 months, I don't remember exactly).

michaelklishin commented 10 years ago

One issue with Emacs modes w/ indentation is that they are notoriously difficult to test, so regressions are possible.

Can we please be more specific than "work normally"?

jimeh commented 10 years ago

Ok, to be more specific of what I expect as "normal" behavior, the original example file above is correctly indented. Feature at level 0, it's description and Scenario statements one level down from Freature. And step statements one level deeper than Scenario statements.

Feature: a feature
  A feature to do stuff

  Scenario: a scenario
    Given something
    When something happens
    Then something cool is shown

  Scenario: another scenario
    Given something else
    When something different happens
    Then something cool is shown yet again

At least that's what I except, but as I'm not a super heavy Cucumber user or really involved in the community, there's a chance I'm just simply wrong.

However, right now, if I don't manually type space to insert indentation, typing out the example above would end up without any indentation at all:

Feature: a feature
A feature to do stuff

Scenario: a scenario
Given something
When something happens
Then something cool is shown

Scenario: another scenario
Given something else
When something different happens
Then something cool is shown yet again

And pressing TAB, which in Emacs typically just changes indentation to the correct level, rather than just further indenting like other editors, currently seems to just remove all indentation. Suggesting that it thinks nothing should be indented.

If it helps, I'll can try older versions after work to find the commit that caused the change in indentation behavior.

michaelklishin commented 10 years ago

I've pushed 2 commits that should help with indentation. Please give the most recent version a try.

iquiw commented 10 years ago

My problem was solved, thank you.

jimeh commented 10 years ago

Seems to have solved my indentation issue too :)