Skip to content

Commit

Permalink
Use em_delete in key_delete
Browse files Browse the repository at this point in the history
When the editing mode is emacs, use `em_delete` in `key_delete`. We need
to add a condition though to `em_delete`, because it implements both
`delete-char` and `end-of-file`. We only want the `end-of-file` behavior
is the key is really Ctrl-D.
  • Loading branch information
etiennebarrie committed Jan 17, 2023
1 parent fe698a0 commit f4857c8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1957,8 +1957,10 @@ def finish
end

private def key_delete(key)
if @config.editing_mode_is?(:vi_insert, :emacs)
if @config.editing_mode_is?(:vi_insert)
ed_delete_next_char(key)
elsif @config.editing_mode_is?(:emacs)
em_delete(key)
end
end

Expand Down Expand Up @@ -2664,7 +2666,7 @@ def finish
alias_method :kill_whole_line, :em_kill_line

private def em_delete(key)
if @line.empty? and (not @is_multiline or @buffer_of_lines.size == 1)
if @line.empty? and (not @is_multiline or @buffer_of_lines.size == 1) and key == 4
@line = nil
if @buffer_of_lines.size > 1
scroll_down(@highest_in_all - @first_line_started_from)
Expand Down

0 comments on commit f4857c8

Please sign in to comment.