From dc7244fa1625a30fde2641b1d86ca42e87852866 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 8 Jun 2013 12:06:49 -0500 Subject: make sure plugins can handle not going through read_line --- lib/Reply/Plugin/FancyPrompt.pm | 5 ++++- lib/Reply/Plugin/Nopaste.pm | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/Reply/Plugin/FancyPrompt.pm b/lib/Reply/Plugin/FancyPrompt.pm index 1f36d45..7a0d415 100644 --- a/lib/Reply/Plugin/FancyPrompt.pm +++ b/lib/Reply/Plugin/FancyPrompt.pm @@ -22,19 +22,22 @@ sub new { my $class = shift; my $self = $class->SUPER::new(@_); $self->{counter} = 0; + $self->{prompted} = 0; return $self; } sub prompt { my $self = shift; my ($next) = @_; + $self->{prompted} = 1; return $self->{counter} . $next->(); } sub loop { my $self = shift; my ($continue) = @_; - $self->{counter}++; + $self->{counter}++ if $self->{prompted}; + $self->{prompted} = 0; $continue; } diff --git a/lib/Reply/Plugin/Nopaste.pm b/lib/Reply/Plugin/Nopaste.pm index 566c668..7265dc9 100644 --- a/lib/Reply/Plugin/Nopaste.pm +++ b/lib/Reply/Plugin/Nopaste.pm @@ -76,7 +76,10 @@ sub loop { my $line = delete $self->{line}; my $result = delete $self->{result}; - $self->{history} .= "$prompt$line$result"; + $self->{history} .= "$prompt$line$result" + if defined $prompt + && defined $line + && defined $result; $continue; } -- cgit v1.2.3-54-g00ecf