зеркало из https://github.com/github/ruby.git
Use existing instances for LineEditor and Config
This commit is contained in:
Родитель
a66bc2c011
Коммит
3b7862c8e8
|
@ -46,10 +46,13 @@ module Reline
|
|||
end
|
||||
|
||||
def push(*val)
|
||||
diff = size + val.size - @@config.history_size
|
||||
shift(diff) if diff > 0
|
||||
super(*(val.map{ |v| String.new(v, encoding: Encoding::default_external) }))
|
||||
end
|
||||
|
||||
def <<(val)
|
||||
shift if size + 1 > @@config.history_size
|
||||
super(String.new(val, encoding: Encoding::default_external))
|
||||
end
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
|
|||
def setup
|
||||
Reline.send(:test_mode)
|
||||
@prompt = '> '
|
||||
@config = Reline::Config.new # Emacs mode is default
|
||||
@config = Reline.class_variable_get(:@@config) # Emacs mode is default
|
||||
@line_editor = Reline.class_variable_get(:@@line_editor)
|
||||
@encoding = (RELINE_TEST_ENCODING rescue Encoding.default_external)
|
||||
@line_editor = Reline::LineEditor.new(@config)
|
||||
@line_editor.reset(@prompt, @encoding)
|
||||
end
|
||||
|
||||
|
|
|
@ -4,12 +4,13 @@ class Reline::KeyActor::ViInsert::Test < Reline::TestCase
|
|||
def setup
|
||||
Reline.send(:test_mode)
|
||||
@prompt = '> '
|
||||
@config = Reline::Config.new
|
||||
@config = Reline.class_variable_get(:@@config) # Emacs mode is default
|
||||
@config.read_lines(<<~LINES.split(/(?<=\n)/))
|
||||
set editing-mode vi
|
||||
LINES
|
||||
@line_editor = Reline::LineEditor.new(@config)
|
||||
@line_editor.reset(@prompt, (RELINE_TEST_ENCODING rescue Encoding.default_external))
|
||||
@line_editor = Reline.class_variable_get(:@@line_editor)
|
||||
@encoding = (RELINE_TEST_ENCODING rescue Encoding.default_external)
|
||||
@line_editor.reset(@prompt, @encoding)
|
||||
end
|
||||
|
||||
def test_vi_command_mode
|
||||
|
|
Загрузка…
Ссылка в новой задаче