File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt
1515- [ PHP] Prefer the longest step keyword ([ #403 ] ( https://github.com/cucumber/gherkin/pull/403 ) )
1616- [ Go] Prefer the longest step keyword ([ #403 ] ( https://github.com/cucumber/gherkin/pull/404 ) )
1717- [ JavaScript] Prefer the longest step keyword ([ #407 ] ( https://github.com/cucumber/gherkin/pull/407 ) )
18+ - [ Perl] Prefer the longest step keyword ([ #408 ] ( https://github.com/cucumber/gherkin/pull/408 ) )
1819- [ Ruby] Prefer the longest step keyword ([ #409 ] ( https://github.com/cucumber/gherkin/pull/409 ) )
1920- [ Python] Prefer the longest step keyword ([ #410 ] ( https://github.com/cucumber/gherkin/pull/410 ) )
2021
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ use List::Util qw(any first reduce);
88our $LANGUAGE_RE = qr / ^\s *#\s *language\s *:\s *([a-zA-Z\- _]+)\s *$ / o ;
99
1010use Class::XSAccessor accessors => [
11- qw/ dialect _default_dialect_name _indent_to_remove _active_doc_string_separator _keyword_types / ,
11+ qw/ dialect _default_dialect_name _indent_to_remove _active_doc_string_separator _keyword_types _sorted_step_keywords / ,
1212];
1313
1414use Cucumber::Messages;
@@ -51,6 +51,13 @@ sub change_dialect {
5151 [ @{ $self -> dialect-> And }, @{ $self -> dialect-> But } ],
5252 Cucumber::Messages::Step::KEYWORDTYPE_CONJUNCTION);
5353 $self -> _keyword_types( $keyword_types );
54+ $self -> _sorted_step_keywords(
55+ [ sort {
56+ length $b <=> length $a # longest keyword first (See #400)
57+ } map {
58+ @{ $self -> dialect-> $_ }
59+ } qw/ Given When Then And But/ ]
60+ );
5461}
5562
5663sub reset {
@@ -213,7 +220,7 @@ sub _unescaped_docstring {
213220
214221sub match_StepLine {
215222 my ( $self , $token ) = @_ ;
216- my @keywords = map { @{ $self -> dialect -> $_ } } qw/ Given When Then And But / ;
223+ my @keywords = @{ $self -> _sorted_step_keywords } ;
217224 my $line = $token -> line;
218225
219226 for my $keyword (@keywords ) {
You can’t perform that action at this time.
0 commit comments