[ruby/reline] @convert_meta is true unless 8-bit characters
If Reline::IOGate.encoding contains 7-bit characters, convert-meta will set it On. Because in readline(3): > The default is On, but readline will set it to Off if the locale contains eight-bit characters. As far as I know, 7-bit encoding used in terminals is only US-ASCII. https://github.com/ruby/reline/commit/b71d1fa496
This commit is contained in:
parent
519a945efc
commit
5f1975a454
@ -67,6 +67,7 @@ class Reline::Config
|
|||||||
@keyseq_timeout = 500
|
@keyseq_timeout = 500
|
||||||
@test_mode = false
|
@test_mode = false
|
||||||
@autocompletion = false
|
@autocompletion = false
|
||||||
|
@convert_meta = true if seven_bit_encoding?(Reline::IOGate.encoding)
|
||||||
end
|
end
|
||||||
|
|
||||||
def reset
|
def reset
|
||||||
@ -387,4 +388,8 @@ class Reline::Config
|
|||||||
end
|
end
|
||||||
ret
|
ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private def seven_bit_encoding?(encoding)
|
||||||
|
encoding == Encoding::US_ASCII
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -11,12 +11,14 @@ class Reline::Config::Test < Reline::TestCase
|
|||||||
Dir.mkdir(@tmpdir)
|
Dir.mkdir(@tmpdir)
|
||||||
end
|
end
|
||||||
Dir.chdir(@tmpdir)
|
Dir.chdir(@tmpdir)
|
||||||
|
Reline.test_mode
|
||||||
@config = Reline::Config.new
|
@config = Reline::Config.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
Dir.chdir(@pwd)
|
Dir.chdir(@pwd)
|
||||||
FileUtils.rm_rf(@tmpdir)
|
FileUtils.rm_rf(@tmpdir)
|
||||||
|
Reline.test_reset
|
||||||
@config.reset
|
@config.reset
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -81,6 +83,22 @@ class Reline::Config::Test < Reline::TestCase
|
|||||||
assert_equal '(Emacs)', @config.instance_variable_get(:@emacs_mode_string)
|
assert_equal '(Emacs)', @config.instance_variable_get(:@emacs_mode_string)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_encoding_is_ascii
|
||||||
|
@config.reset
|
||||||
|
Reline::IOGate.reset(encoding: Encoding::US_ASCII)
|
||||||
|
@config = Reline::Config.new
|
||||||
|
|
||||||
|
assert_equal true, @config.convert_meta
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_encoding_is_not_ascii
|
||||||
|
@config.reset
|
||||||
|
Reline::IOGate.reset(encoding: Encoding::UTF_8)
|
||||||
|
@config = Reline::Config.new
|
||||||
|
|
||||||
|
assert_equal nil, @config.convert_meta
|
||||||
|
end
|
||||||
|
|
||||||
def test_comment_line
|
def test_comment_line
|
||||||
@config.read_lines([" #a: error\n"])
|
@config.read_lines([" #a: error\n"])
|
||||||
assert_not_include @config.key_bindings, nil
|
assert_not_include @config.key_bindings, nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user