From bb6d45cfeecc8e16ec22e89ab40fb6b56177da7f Mon Sep 17 00:00:00 2001 From: aycabta Date: Sun, 5 Sep 2021 23:29:18 +0900 Subject: [PATCH] [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 735a5afad8..4b06d07b4d 100644 --- a/lib/reline.rb +++ b/lib/reline.rb @@ -18,9 +18,21 @@ module Reline 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)