diff options
author | aycabta <aycabta@gmail.com> | 2019-10-16 22:34:58 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2019-10-16 22:35:58 +0900 |
commit | 7df227804af8eefac9d82cf449cab09c086aea60 (patch) | |
tree | 007bd81227111e92cf2985b791f2c3b3b804abc9 | |
parent | f8fb51c976313b8053412c80f3f7474cdd89b4b3 (diff) | |
download | ruby-7df227804af8eefac9d82cf449cab09c086aea60.tar.gz |
Support multiline history in incremental search
-rw-r--r-- | lib/reline/line_editor.rb | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 9223e55e5f..a62ed0e45d 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -1191,11 +1191,25 @@ class Reline::LineEditor end end if hit - @searching_prompt = "(reverse-i-search)`%s': %s" % [search_word, hit] - @line = hit + if @is_multiline + @buffer_of_lines = hit.split("\n") + @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty? + @line_index = @buffer_of_lines.size - 1 + @line = @buffer_of_lines.last + @rerender_all = true + @searching_prompt = "(reverse-i-search)`%s'" % [search_word] + else + @line = hit + @searching_prompt = "(reverse-i-search)`%s': %s" % [search_word, hit] + end last_hit = hit else - @searching_prompt = "(failed reverse-i-search)`%s': %s" % [search_word, last_hit] + if @is_multiline + @rerender_all = true + @searching_prompt = "(failed reverse-i-search)`%s'" % [search_word] + else + @searching_prompt = "(failed reverse-i-search)`%s': %s" % [search_word, last_hit] + end end end end |