File tree Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ class InvalidInputrc < RuntimeError
38
38
vi-ins-mode-icon
39
39
emacs-mode-string
40
40
enable-bracketed-paste
41
+ isearch-terminators
41
42
}
42
43
VARIABLE_NAME_SYMBOLS = VARIABLE_NAMES . map { |v | :"#{ v . tr ( ?-, ?_) } " }
43
44
VARIABLE_NAME_SYMBOLS . each do |v |
@@ -238,7 +239,7 @@ def bind_variable(name, value)
238
239
when 'completion-query-items'
239
240
@completion_query_items = value . to_i
240
241
when 'isearch-terminators'
241
- @isearch_terminators = instance_eval ( value )
242
+ @isearch_terminators = retrieve_string ( value )
242
243
when 'editing-mode'
243
244
case value
244
245
when 'emacs'
Original file line number Diff line number Diff line change @@ -1593,9 +1593,11 @@ def finish
1593
1593
searcher = generate_searcher
1594
1594
searcher . resume ( key )
1595
1595
@searching_prompt = "(reverse-i-search)`': "
1596
+ termination_keys = [ "\C -j" . ord ]
1597
+ termination_keys . concat ( @config . isearch_terminators &.chars &.map ( &:ord ) ) if @config . isearch_terminators
1596
1598
@waiting_proc = -> ( k ) {
1597
1599
case k
1598
- when " \C -j" . ord
1600
+ when * termination_keys
1599
1601
if @history_pointer
1600
1602
buffer = Reline ::HISTORY [ @history_pointer ]
1601
1603
else
Original file line number Diff line number Diff line change @@ -1894,6 +1894,36 @@ def test_search_history_by_last_determined
1894
1894
assert_cursor_max ( 0 )
1895
1895
end
1896
1896
1897
+ def test_search_history_with_isearch_terminator
1898
+ @config . read_lines ( <<~LINES . split ( /(?<=\n )/ ) )
1899
+ set isearch-terminators "XYZ"
1900
+ LINES
1901
+ Reline ::HISTORY . concat ( [
1902
+ '1235' , # old
1903
+ '12aa' ,
1904
+ '1234' # new
1905
+ ] )
1906
+ assert_line ( '' )
1907
+ assert_byte_pointer_size ( '' )
1908
+ assert_cursor ( 0 )
1909
+ assert_cursor_max ( 0 )
1910
+ input_keys ( "\C -r12a" )
1911
+ assert_line ( '12aa' )
1912
+ assert_byte_pointer_size ( '' )
1913
+ assert_cursor ( 0 )
1914
+ assert_cursor_max ( 0 ) # doesn't determine yet
1915
+ input_keys ( 'Y' )
1916
+ assert_line ( '12aa' )
1917
+ assert_byte_pointer_size ( '' )
1918
+ assert_cursor ( 0 )
1919
+ assert_cursor_max ( 4 )
1920
+ input_keys ( 'x' )
1921
+ assert_line ( 'x12aa' )
1922
+ assert_byte_pointer_size ( 'x' )
1923
+ assert_cursor ( 1 )
1924
+ assert_cursor_max ( 5 )
1925
+ end
1926
+
1897
1927
def test_em_set_mark_and_em_exchange_mark
1898
1928
input_keys ( 'aaa bbb ccc ddd' )
1899
1929
assert_byte_pointer_size ( 'aaa bbb ccc ddd' )
You can’t perform that action at this time.
0 commit comments