Skip to content

Commit

Permalink
Insert newline in the middle of buffer just after dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed Jan 12, 2022
1 parent da4a7aa commit 0c76631
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/reline/line_editor.rb
Expand Up @@ -476,6 +476,7 @@ def rerender
@just_cursor_moving = false
return
elsif @previous_line_index or new_highest_in_this != @highest_in_this
clear_dialog_with_content
rerender_changed_current_line
@previous_line_index = nil
rendered = true
Expand Down
21 changes: 21 additions & 0 deletions test/reline/yamatanooroti/test_rendering.rb
Expand Up @@ -1289,6 +1289,27 @@ def test_clear_dialog_when_adding_new_line_to_end_of_buffer
EOC
end

def test_insert_newline_in_the_middle_of_buffer_just_after_dialog
start_terminal(10, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.')
write("class A\n def a\n 3\n end\nend")
write("\n")
write("\C-p\C-p\C-p\C-p\C-p\C-e\C-hS")
write("\M-\x0D")
write(" 3")
close
assert_screen(<<~'EOC')
prompt> end
prompt> end
=> :a
prompt> class S
prompt> 3
prompt> def a
prompt> 3
prompt> end
prompt> end
EOC
end

def write_inputrc(content)
File.open(@inputrc_file, 'w') do |f|
f.write content
Expand Down

0 comments on commit 0c76631

Please sign in to comment.