Skip to content

Commit

Permalink
Merge pull request #280 from jethrodaniel/chr-encoding-issue
Browse files Browse the repository at this point in the history
ensure reline's encoding is used when reading inputrc character values
  • Loading branch information
aycabta committed Apr 20, 2021
2 parents 76c8637 + cf372fc commit e4ac748
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/reline/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,8 @@ def bind_variable(name, value)
end

def retrieve_string(str)
if str =~ /\A"(.*)"\z/
parse_keyseq($1).map(&:chr).join
else
parse_keyseq(str).map(&:chr).join
end
str = $1 if str =~ /\A"(.*)"\z/
parse_keyseq(str).map { |c| c.chr(Reline::IOGate.encoding) }.join
end

def bind_key(key, func_name)
Expand Down
10 changes: 10 additions & 0 deletions test/reline/test_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,16 @@ def test_inputrc
ENV['INPUTRC'] = inputrc_backup
end

def test_inputrc_with_utf
@config.read_lines(<<~'LINES'.lines)
set editing-mode vi
set vi-cmd-mode-string 🍸
set vi-ins-mode-string 🍶
LINES
assert_equal @config.vi_cmd_mode_string, "🍸"
assert_equal @config.vi_ins_mode_string, "🍶"
end

def test_xdg_config_home
home_backup = ENV['HOME']
xdg_config_home_backup = ENV['XDG_CONFIG_HOME']
Expand Down

0 comments on commit e4ac748

Please sign in to comment.