diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-06-08 12:06:49 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-06-08 12:06:49 -0500 |
commit | dc7244fa1625a30fde2641b1d86ca42e87852866 (patch) | |
tree | a07c93dce8e0d0bc11422a3330a46af68b645926 /lib/Reply/Plugin | |
parent | f4775be782ef0cd1003190169b539b3ba2367292 (diff) | |
download | reply-dc7244fa1625a30fde2641b1d86ca42e87852866.tar.gz reply-dc7244fa1625a30fde2641b1d86ca42e87852866.zip |
make sure plugins can handle not going through read_line
Diffstat (limited to 'lib/Reply/Plugin')
-rw-r--r-- | lib/Reply/Plugin/FancyPrompt.pm | 5 | ||||
-rw-r--r-- | 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; } |