mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parent
294552ca6c
commit
b52bc4a9c2
3 changed files with 35 additions and 2 deletions
|
@ -38,6 +38,7 @@ class Reline::Config
|
||||||
vi-ins-mode-icon
|
vi-ins-mode-icon
|
||||||
emacs-mode-string
|
emacs-mode-string
|
||||||
enable-bracketed-paste
|
enable-bracketed-paste
|
||||||
|
isearch-terminators
|
||||||
}
|
}
|
||||||
VARIABLE_NAME_SYMBOLS = VARIABLE_NAMES.map { |v| :"#{v.tr(?-, ?_)}" }
|
VARIABLE_NAME_SYMBOLS = VARIABLE_NAMES.map { |v| :"#{v.tr(?-, ?_)}" }
|
||||||
VARIABLE_NAME_SYMBOLS.each do |v|
|
VARIABLE_NAME_SYMBOLS.each do |v|
|
||||||
|
@ -238,7 +239,7 @@ class Reline::Config
|
||||||
when 'completion-query-items'
|
when 'completion-query-items'
|
||||||
@completion_query_items = value.to_i
|
@completion_query_items = value.to_i
|
||||||
when 'isearch-terminators'
|
when 'isearch-terminators'
|
||||||
@isearch_terminators = instance_eval(value)
|
@isearch_terminators = retrieve_string(value)
|
||||||
when 'editing-mode'
|
when 'editing-mode'
|
||||||
case value
|
case value
|
||||||
when 'emacs'
|
when 'emacs'
|
||||||
|
|
|
@ -1593,9 +1593,11 @@ class Reline::LineEditor
|
||||||
searcher = generate_searcher
|
searcher = generate_searcher
|
||||||
searcher.resume(key)
|
searcher.resume(key)
|
||||||
@searching_prompt = "(reverse-i-search)`': "
|
@searching_prompt = "(reverse-i-search)`': "
|
||||||
|
termination_keys = ["\C-j".ord]
|
||||||
|
termination_keys.concat(@config.isearch_terminators&.chars&.map(&:ord)) if @config.isearch_terminators
|
||||||
@waiting_proc = ->(k) {
|
@waiting_proc = ->(k) {
|
||||||
case k
|
case k
|
||||||
when "\C-j".ord
|
when *termination_keys
|
||||||
if @history_pointer
|
if @history_pointer
|
||||||
buffer = Reline::HISTORY[@history_pointer]
|
buffer = Reline::HISTORY[@history_pointer]
|
||||||
else
|
else
|
||||||
|
|
|
@ -1894,6 +1894,36 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
|
||||||
assert_cursor_max(0)
|
assert_cursor_max(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_search_history_with_isearch_terminator
|
||||||
|
@config.read_lines(<<~LINES.split(/(?<=\n)/))
|
||||||
|
set isearch-terminators "XYZ"
|
||||||
|
LINES
|
||||||
|
Reline::HISTORY.concat([
|
||||||
|
'1235', # old
|
||||||
|
'12aa',
|
||||||
|
'1234' # new
|
||||||
|
])
|
||||||
|
assert_line('')
|
||||||
|
assert_byte_pointer_size('')
|
||||||
|
assert_cursor(0)
|
||||||
|
assert_cursor_max(0)
|
||||||
|
input_keys("\C-r12a")
|
||||||
|
assert_line('12aa')
|
||||||
|
assert_byte_pointer_size('')
|
||||||
|
assert_cursor(0)
|
||||||
|
assert_cursor_max(0) # doesn't determine yet
|
||||||
|
input_keys('Y')
|
||||||
|
assert_line('12aa')
|
||||||
|
assert_byte_pointer_size('')
|
||||||
|
assert_cursor(0)
|
||||||
|
assert_cursor_max(4)
|
||||||
|
input_keys('x')
|
||||||
|
assert_line('x12aa')
|
||||||
|
assert_byte_pointer_size('x')
|
||||||
|
assert_cursor(1)
|
||||||
|
assert_cursor_max(5)
|
||||||
|
end
|
||||||
|
|
||||||
def test_em_set_mark_and_em_exchange_mark
|
def test_em_set_mark_and_em_exchange_mark
|
||||||
input_keys('aaa bbb ccc ddd')
|
input_keys('aaa bbb ccc ddd')
|
||||||
assert_byte_pointer_size('aaa bbb ccc ddd')
|
assert_byte_pointer_size('aaa bbb ccc ddd')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue