diff options
author | Tim Pope <[email protected]> | 2022-02-18 16:11:33 -0500 |
---|---|---|
committer | git <[email protected]> | 2022-02-22 18:52:52 +0900 |
commit | 37d5890e4941cedf6918821b29bb4a7e3a092e62 (patch) | |
tree | 5c0594bca5da7676d9dc8ddc1c1d3c158c744315 /lib | |
parent | 50098f4b61179a32f9df92e5d0e58cb911f71c86 (diff) |
[ruby/reline] Fix support for emacs-ctlx and emacs-meta keymaps
The existing implementation, given the below .inputrc, erroneously
creates a "C-v" key binding:
set keymap emacs-ctlx
"\C-v": "[C-x C-v was pressed]"
This fixes it to instead create a "C-x C-v" keybinding.
https://github.com/ruby/reline/commit/719f52d231
Diffstat (limited to 'lib')
-rw-r--r-- | lib/reline/config.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/reline/config.rb b/lib/reline/config.rb index 5ef5ce4e8d..1bb12a2506 100644 --- a/lib/reline/config.rb +++ b/lib/reline/config.rb @@ -55,6 +55,7 @@ class Reline::Config @if_stack = nil @editing_mode_label = :emacs @keymap_label = :emacs + @keymap_prefix = [] @key_actors = {} @key_actors[:emacs] = Reline::KeyActor::Emacs.new @key_actors[:vi_insert] = Reline::KeyActor::ViInsert.new @@ -221,7 +222,7 @@ class Reline::Config key, func_name = $1, $2 keystroke, func = bind_key(key, func_name) next unless keystroke - @additional_key_bindings[@keymap_label][keystroke] = func + @additional_key_bindings[@keymap_label][@keymap_prefix + keystroke] = func end end unless @if_stack.empty? @@ -292,18 +293,29 @@ class Reline::Config when 'emacs' @editing_mode_label = :emacs @keymap_label = :emacs + @keymap_prefix = [] when 'vi' @editing_mode_label = :vi_insert @keymap_label = :vi_insert + @keymap_prefix = [] end when 'keymap' case value - when 'emacs', 'emacs-standard', 'emacs-meta', 'emacs-ctlx' + when 'emacs', 'emacs-standard' @keymap_label = :emacs + @keymap_prefix = [] + when 'emacs-ctlx' + @keymap_label = :emacs + @keymap_prefix = [?\C-x.ord] + when 'emacs-meta' + @keymap_label = :emacs + @keymap_prefix = [?\e.ord] when 'vi', 'vi-move', 'vi-command' @keymap_label = :vi_command + @keymap_prefix = [] when 'vi-insert' @keymap_label = :vi_insert + @keymap_prefix = [] end when 'keyseq-timeout' @keyseq_timeout = value.to_i |