Skip to content

Commit

Permalink
Enter newline if cursor position is middle of input
Browse files Browse the repository at this point in the history
  • Loading branch information
ima1zumi committed Jan 5, 2025
1 parent f09e7b1 commit 2e4a7d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
13 changes: 3 additions & 10 deletions lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1673,17 +1673,10 @@ def finish
finish
end
else
if @line_index == (@buffer_of_lines.size - 1)
if confirm_multiline_termination
finish
else
key_newline(key)
end
else
# should check confirm_multiline_termination to finish?
@line_index = @buffer_of_lines.size - 1
@byte_pointer = current_line.bytesize
if @line_index == @buffer_of_lines.size - 1 && confirm_multiline_termination
finish
else
key_newline(key)
end
end
else
Expand Down
8 changes: 4 additions & 4 deletions test/reline/yamatanooroti/test_rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -813,15 +813,15 @@ def test_autowrap_in_the_middle_of_a_line
close
end

def test_terminate_in_the_middle_of_lines
def test_newline_in_the_middle_of_lines
start_terminal(5, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
write("def hoge\n 1\n 2\n 3\n 4\nend\n")
write("\C-p\C-p\C-p\C-e\n")
assert_screen(<<~EOC)
prompt> def hoge
prompt> 1
prompt> 2
prompt> 3
prompt> 4
prompt> end
=> :hoge
prompt>
EOC
close
Expand Down

0 comments on commit 2e4a7d8

Please sign in to comment.