Skip to content

Commit

Permalink
make sure that tabs in heredocs get properly dedented.
Browse files Browse the repository at this point in the history
  • Loading branch information
timo committed Aug 1, 2013
1 parent bb86d1a commit e8320df
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Perl6/Actions.nqp
Expand Up @@ -14,7 +14,20 @@ role STDActions {
method trim_heredoc($doc, $stop, $origast) {
$origast.pop();
$origast.pop();
my int $indent := -nqp::chars($stop.MATCH<ws>.Str);

my str $ws := $stop.MATCH<ws>.Str;
my int $actualchars := nqp::chars($ws);
my int $indent := -$actualchars;

my int $tabstop := $*W.find_symbol(['$?TABSTOP']);
my int $checkidx := 0;
while $checkidx < $actualchars {
if nqp::substr($ws, $checkidx, 1) eq "\t" {
$indent := $indent - ($tabstop - 1);
}
$checkidx := $checkidx + 1;
}

my $docast := $doc.MATCH.ast;
if $docast.has_compile_time_value {
my $dedented := nqp::unbox_s($docast.compile_time_value.indent($indent));
Expand Down

0 comments on commit e8320df

Please sign in to comment.