summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/reline/line_editor.rb3
-rw-r--r--test/reline/yamatanooroti/test_rendering.rb11
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb
index f8be32e913f..236993ffb04 100644
--- a/lib/reline/line_editor.rb
+++ b/lib/reline/line_editor.rb
@@ -933,6 +933,7 @@ class Reline::LineEditor
finish
return
end
+ old_line = @line.dup
@first_char = false
completion_occurs = false
if @config.editing_mode_is?(:emacs, :vi_insert) and key.char == "\C-i".ord
@@ -964,7 +965,7 @@ class Reline::LineEditor
if not Reline::IOGate.in_pasting? and @just_cursor_moving.nil?
if @previous_line_index and @buffer_of_lines[@previous_line_index] == @line
@just_cursor_moving = true
- elsif @previous_line_index.nil? and @buffer_of_lines[@line_index] == @line
+ elsif @previous_line_index.nil? and @buffer_of_lines[@line_index] == @line and old_line == @line
@just_cursor_moving = true
else
@just_cursor_moving = false
diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb
index 84c0580e4bd..1dc5ac3ea89 100644
--- a/test/reline/yamatanooroti/test_rendering.rb
+++ b/test/reline/yamatanooroti/test_rendering.rb
@@ -441,6 +441,17 @@ begin
EOC
end
+ def test_backspace_until_returns_to_initial
+ start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}, startup_message: 'Multiline REPL.')
+ write("ABC")
+ write("\C-h\C-h\C-h")
+ close
+ assert_screen(<<~EOC)
+ Multiline REPL.
+ prompt>
+ EOC
+ end
+
private def write_inputrc(content)
File.open(@inputrc_file, 'w') do |f|
f.write content