Permalink
Browse files

Fix same-line whitespace before block start and after block end

  • Loading branch information...
1 parent c19e6e6 commit 07e401c8fbf74ad3c8dec8bdf86135cfe1034783 @jonswar committed Oct 9, 2012
Showing with 9 additions and 2 deletions.
  1. +2 −0 Changes
  2. +2 −2 lib/Mason/Tidy.pm
  3. +5 −0 lib/Mason/Tidy/t/Basic.pm
View
@@ -4,6 +4,8 @@ Revision history for Mason-Tidy
2.58 Oct 7, 2012
+- Fix same-line whitespace before block start and after block end
+
2.57 Oct 7, 2012
- Fix misclassification of % at beginning of lines inside sections or tags
View
@@ -128,11 +128,11 @@ method tidy_method ($source) {
my ($end_line) =
grep { $lines[$_] =~ /^\s*<\/%perl>\s*$/ } ( $cur_line + 1 .. $last_line );
if ($end_line) {
- $add_element->( 'begin_perl_block', '<%perl>' );
+ $add_element->( 'begin_perl_block', $line );
foreach my $line ( @lines[ $cur_line + 1 .. $end_line - 1 ] ) {
$add_element->( 'perl_line', $line );
}
- $add_element->( 'end_perl_block', '</%perl>' );
+ $add_element->( 'end_perl_block', $lines[$end_line] );
$cur_line = $end_line;
next;
}
@@ -217,6 +217,10 @@ sub test_blocks_and_newlines : Tests {
expect => '<%perl>\n\n\n my $foo = 3;\n\n\n my $bar = 4;\n\n\n</%perl>',
);
tidy(
+ source => ' <%perl>\nmy $foo = 3;\n</%perl> ',
+ expect => ' <%perl>\n my $foo = 3;\n</%perl> '
+ );
+ tidy(
source => "<%init>my \$foo=5;</%init>",
expect => "<%init>my \$foo = 5;</%init>"
);
@@ -236,6 +240,7 @@ sub test_blocks_and_newlines : Tests {
source => '<%init>\n\nmy $foo = 3;\n\nmy $bar = 4;\n\n</%init>',
expect => '<%init>\nmy $foo = 3;\nmy $bar = 4;\n</%init>',
);
+ tidy( source => ' <%init>\nmy $foo = 3;\n</%init> ' );
}
sub test_tags : Tests {

0 comments on commit 07e401c

Please sign in to comment.