Skip to content

Commit

Permalink
Add ed_force_submit to allow input confirmation on non-final lines
Browse files Browse the repository at this point in the history
  • Loading branch information
ima1zumi committed Jan 6, 2025
1 parent 2e4a7d8 commit 9557354
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,11 @@ def finish
end
end

private def ed_force_submit(_key)
process_insert(force: true)
finish
end

private def em_delete_prev_char(key, arg: 1)
arg.times do
if @byte_pointer == 0 and @line_index > 0
Expand Down
17 changes: 17 additions & 0 deletions test/reline/yamatanooroti/test_rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,23 @@ def test_newline_in_the_middle_of_lines
close
end

def test_ed_force_submit_in_the_middle_of_lines
write_inputrc <<~LINES
"\\C-a": ed_force_submit
LINES
start_terminal(5, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
write("def hoge\nend")
write("\C-p\C-a")
assert_screen(<<~EOC)
Multiline REPL.
prompt> def hoge
prompt> end
=> :hoge
prompt>
EOC
close
end

def test_dynamic_prompt_returns_empty
start_terminal(5, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --dynamic-prompt-returns-empty}, startup_message: 'Multiline REPL.')
write("def hoge\nend\n")
Expand Down

0 comments on commit 9557354

Please sign in to comment.