default => sub { '> ' }
);
+has 'line_depth' => (
+ is => 'rw', required => 1, lazy => 1,
+ default => sub { 0 }
+);
+
around 'read' => sub {
my $orig = shift;
my ($self, @args) = @_;
my $line = $self->$orig(@args);
if (defined $line) {
- while (needs_continuation($line)) {
+ while ($self->line_needs_continuation($line)) {
my $orig_prompt = $self->prompt;
$self->prompt($self->continuation_prompt);
+ $self->line_depth($self->line_depth + 1);
my $append = $self->read(@args);
+ $self->line_depth($self->line_depth - 1);
+
$line .= $append if defined($append);
$self->prompt($orig_prompt);
return $line;
};
-sub needs_continuation
+sub line_needs_continuation
{
+ my $repl = shift;
my $line = shift;
my $document = PPI::Document->new(\$line);
return 0 if !defined($document);