Skip to content

Commit ebc3e0f

Browse files
committed
Reline::Key supports the comparison with Integer
1 parent 9a77fc9 commit ebc3e0f

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lib/reline.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,21 @@ class ConfigEncodingConversionError < StandardError; end
1818

1919
Key = Struct.new('Key', :char, :combined_char, :with_meta) do
2020
def match?(key)
21-
(key.char.nil? or char.nil? or char == key.char) and
22-
(key.combined_char.nil? or combined_char.nil? or combined_char == key.combined_char) and
23-
(key.with_meta.nil? or with_meta.nil? or with_meta == key.with_meta)
21+
if key.instance_of?(Reline::Key)
22+
(key.char.nil? or char.nil? or char == key.char) and
23+
(key.combined_char.nil? or combined_char.nil? or combined_char == key.combined_char) and
24+
(key.with_meta.nil? or with_meta.nil? or with_meta == key.with_meta)
25+
elsif key.is_a?(Integer)
26+
if not combined_char.nil? and combined_char == key
27+
true
28+
elsif not char.nil? and char == key
29+
true
30+
else
31+
false
32+
end
33+
else
34+
false
35+
end
2436
end
2537
end
2638
CursorPos = Struct.new(:x, :y)

0 commit comments

Comments
 (0)