]> ruderich.org/simon Gitweb - fcscs/fcscs.git/commitdiff
cleanup handler selection
authorSimon Ruderich <simon@ruderich.org>
Sun, 24 Jan 2016 00:06:27 +0000 (01:06 +0100)
committerSimon Ruderich <simon@ruderich.org>
Sun, 24 Jan 2016 00:06:27 +0000 (01:06 +0100)
bin/fcscs

index 9c33fe95ca06d3c9f7bcc05e261d620af02923d4..8a040f84f3d29624c5cdff96979281fa69d9f9d4 100755 (executable)
--- 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;
         }