summaryrefslogtreecommitdiff
path: root/lib/reline.rb
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2021-09-06 03:58:48 +0900
committergit <svn-admin@ruby-lang.org>2021-09-06 05:23:27 +0900
commit3773296bfc45a60baf9e5cc025bfed2d6b493eaa (patch)
treef584ba4ad6b4ff01edf382dc8b4174e17f474099 /lib/reline.rb
parent56ab22ab3daaedcef428a3ad623010f84e9e687c (diff)
[ruby/reline] Allow Reline::KeyStroke to compare raw and meta-key processed key sequences
https://github.com/ruby/reline/commit/731103f9c9
Diffstat (limited to 'lib/reline.rb')
-rw-r--r--lib/reline.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/reline.rb b/lib/reline.rb
index 3569787a5d..33aa6cdbf1 100644
--- a/lib/reline.rb
+++ b/lib/reline.rb
@@ -390,15 +390,23 @@ module Reline
block.([Reline::Key.new(c, c, false)])
break
else
- if key_stroke.match_status(buffer.dup.push(succ_c)) == :unmatched
+ case key_stroke.match_status(buffer.dup.push(succ_c))
+ when :unmatched
if c == "\e".ord
block.([Reline::Key.new(succ_c, succ_c | 0b10000000, true)])
else
block.([Reline::Key.new(c, c, false), Reline::Key.new(succ_c, succ_c, false)])
end
break
- else
+ when :matching
Reline::IOGate.ungetc(succ_c)
+ when :matched
+ buffer << succ_c
+ expanded = key_stroke.expand(buffer).map{ |expanded_c|
+ Reline::Key.new(expanded_c, expanded_c, false)
+ }
+ block.(expanded)
+ break
end
end
end