From 14126138d777250aac6d90b43f1a271bba91a820 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 24 Jan 2016 01:06:27 +0100 Subject: [PATCH] cleanup handler selection --- bin/fcscs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/bin/fcscs b/bin/fcscs index 9c33fe9..8a040f8 100755 --- a/bin/fcscs +++ b/bin/fcscs @@ -1211,11 +1211,20 @@ RESULT: } debug \%config, 'input', 'running handler'; - my $handler = $config{state}{handler}; # set by user - $handler = $result->{match}->{handler} unless defined $handler; # set by match - $handler = $result->{handler} unless defined $handler; # set by mapping - $handler = $config{handler}{yank} unless defined $handler; # fallback - $handler->($screen, \%config, $result->{match}); + + # Choose handler with falling priority. + my @handlers = ( + $config{state}{handler}, # set by user + $result->{match}->{handler}, # set by match + $result->{handler}, # set by mapping + $config{handler}{yank}, # fallback + ); + foreach my $handler (@handlers) { + next unless defined $handler; + + $handler->($screen, \%config, $result->{match}); + last; + } last; } -- 2.43.2