summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/reline.rb8
-rw-r--r--lib/reline/line_editor.rb4
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/reline.rb b/lib/reline.rb
index f1f82bff72..81619dea77 100644
--- a/lib/reline.rb
+++ b/lib/reline.rb
@@ -16,7 +16,13 @@ module Reline
class ConfigEncodingConversionError < StandardError; end
- Key = Struct.new('Key', :char, :combined_char, :with_meta)
+ 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)
+ end
+ end
CursorPos = Struct.new(:x, :y)
DialogRenderInfo = Struct.new(:pos, :contents, :pointer, :bg_color, :width, :height, keyword_init: true)
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index 50aeac996f..d3020087bf 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -1480,7 +1480,9 @@ class Reline::LineEditor
@last_key = key
@dialogs.each do |dialog|
# The dialog will intercept the key if trap_key is set.
- return if dialog.trap_key and key.combined_char == dialog.trap_key
+ if dialog.trap_key and dialog.trap_key.match?(key)
+ return
+ end
end
@just_cursor_moving = nil
if key.char.nil?