[前][次][番号順一覧][スレッド一覧]

ruby-changes:67614

From: aycabta <ko1@a...>
Date: Mon, 6 Sep 2021 05:23:11 +0900 (JST)
Subject: [ruby-changes:67614] bb6d45cfee (master): [ruby/reline] Reline::Key supports the comparison with Integer

https://git.ruby-lang.org/ruby.git/commit/?id=bb6d45cfee

From bb6d45cfeecc8e16ec22e89ab40fb6b56177da7f Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Sun, 5 Sep 2021 23:29:18 +0900
Subject: [ruby/reline] Reline::Key supports the comparison with Integer

https://github.com/ruby/reline/commit/ebc3e0f673
---
 lib/reline.rb | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/lib/reline.rb b/lib/reline.rb
index 735a5af..4b06d07 100644
--- a/lib/reline.rb
+++ b/lib/reline.rb
@@ -18,9 +18,21 @@ module Reline https://github.com/ruby/ruby/blob/trunk/lib/reline.rb#L18
 
   Key = Struct.new('Key', :char, :combined_char, :with_meta) do
     def match?(key)
-      (key.char.nil? or char.nil? or char == key.char) and
-      (key.combined_char.nil? or combined_char.nil? or combined_char == key.combined_char) and
-      (key.with_meta.nil? or with_meta.nil? or with_meta == key.with_meta)
+      if key.instance_of?(Reline::Key)
+        (key.char.nil? or char.nil? or char == key.char) and
+        (key.combined_char.nil? or combined_char.nil? or combined_char == key.combined_char) and
+        (key.with_meta.nil? or with_meta.nil? or with_meta == key.with_meta)
+      elsif key.is_a?(Integer)
+        if not combined_char.nil? and combined_char == key
+          true
+        elsif not char.nil? and char == key
+          true
+        else
+          false
+        end
+      else
+        false
+      end
     end
   end
   CursorPos = Struct.new(:x, :y)
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]