diff options
author | aycabta <[email protected]> | 2020-11-21 13:08:53 +0900 |
---|---|---|
committer | aycabta <[email protected]> | 2020-12-05 02:58:59 +0900 |
commit | 7624f5275713c3dd2d551058355d9a4544c2ef53 (patch) | |
tree | c6a25d3fcef74fc31f4d832df7b60a56e08722c0 /lib | |
parent | 37a574b527f2c612be46ec8038ff52bf861bf82f (diff) |
[ruby/reline] Forced newline insertion is not just cursor moving
https://github.com/ruby/reline/commit/0e30a49d03
Diffstat (limited to 'lib')
-rw-r--r-- | lib/reline/line_editor.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 868e31aca8..044b7c3159 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -197,7 +197,7 @@ class Reline::LineEditor @searching_prompt = nil @first_char = true @add_newline_to_end_of_buffer = false - @just_cursor_moving = false + @just_cursor_moving = nil @cached_prompt_list = nil @prompt_cache_time = nil @eof = false @@ -246,6 +246,7 @@ class Reline::LineEditor @buffer_of_lines.insert(@line_index + 1, String.new(next_line, encoding: @encoding)) @previous_line_index = @line_index @line_index += 1 + @just_cursor_moving = false end private def calculate_height_by_width(width) @@ -923,6 +924,7 @@ class Reline::LineEditor end def input_key(key) + @just_cursor_moving = nil if key.char.nil? if @first_char @line = nil @@ -958,12 +960,16 @@ class Reline::LineEditor unless completion_occurs @completion_state = CompletionState::NORMAL end - unless Reline::IOGate.in_pasting? + 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 @just_cursor_moving = true + else + @just_cursor_moving = false end + else + @just_cursor_moving = false end if @is_multiline and @auto_indent_proc and not simplified_rendering? process_auto_indent |