summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMark Delk <jethrodaniel@gmail.com>2021-04-13 21:23:07 -0500
committeraycabta <aycabta@gmail.com>2021-06-21 17:58:48 +0900
commita049dfd10a3b9ae24a1822e807398422e87d142f (patch)
treedb6c7545f97aa78a0a4d934ac5d39f9839a07153 /test
parentc2f30aaade9abe103a727a5440325baff58f66ba (diff)
[ruby/reline] ensure reline's encoding is used when reading inputrc character values
This change ensures we use `Reline::IOGate`'s `encoding` when converting characters from their integer values. This fixes an issue that may occur if you have UTF characters in your `.inputrc`, but your default encoding isn't set. For example: ``` > 127864.ord.chr RangeError: 127864 out of char range from (pry):1:in `chr' > Reline::IOGate.encoding => #<Encoding:UTF-8> > 127864.ord.chr(Reline::IOGate.encoding) => "🍸" ``` https://github.com/ruby/reline/commit/cf372fc0fc
Diffstat (limited to 'test')
-rw-r--r--test/reline/test_config.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/reline/test_config.rb b/test/reline/test_config.rb
index 2cca0e71f7..2ada00c154 100644
--- a/test/reline/test_config.rb
+++ b/test/reline/test_config.rb
@@ -286,6 +286,16 @@ class Reline::Config::Test < Reline::TestCase
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']