summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2019-05-27 08:13:48 +0900
committeraycabta <aycabta@gmail.com>2019-05-27 08:13:48 +0900
commit4e2c7783e364f37a748fe0d3a3cd9f96e58287c0 (patch)
treed2556f13544ef07ba709a35888599664fd2e80c4 /lib
parent2805c55aa39bf6127e1e684deb0d5a0291cb6479 (diff)
Check blank history
Diffstat (limited to 'lib')
-rw-r--r--lib/reline/line_editor.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index 7c9eb065b5..32b49dbb7d 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -1037,6 +1037,7 @@ class Reline::LineEditor
if @is_multiline
@line_backup_in_history = whole_buffer
@buffer_of_lines = Reline::HISTORY[@history_pointer].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
@@ -1051,6 +1052,7 @@ class Reline::LineEditor
Reline::HISTORY[@history_pointer] = whole_buffer
@history_pointer -= 1
@buffer_of_lines = Reline::HISTORY[@history_pointer].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
@@ -1096,6 +1098,7 @@ class Reline::LineEditor
Reline::HISTORY[@history_pointer] = whole_buffer
@history_pointer += 1
@buffer_of_lines = Reline::HISTORY[@history_pointer].split("\n")
+ @buffer_of_lines = [String.new(encoding: @encoding)] if @buffer_of_lines.empty?
@line_index = 0
@line = @buffer_of_lines.first
@rerender_all = true