[ruby/reline] Forced newline insertion is not just cursor moving
https://github.com/ruby/reline/commit/0e30a49d03
This commit is contained in:
parent
37a574b527
commit
7624f52757
@ -197,7 +197,7 @@ class Reline::LineEditor
|
|||||||
@searching_prompt = nil
|
@searching_prompt = nil
|
||||||
@first_char = true
|
@first_char = true
|
||||||
@add_newline_to_end_of_buffer = false
|
@add_newline_to_end_of_buffer = false
|
||||||
@just_cursor_moving = false
|
@just_cursor_moving = nil
|
||||||
@cached_prompt_list = nil
|
@cached_prompt_list = nil
|
||||||
@prompt_cache_time = nil
|
@prompt_cache_time = nil
|
||||||
@eof = false
|
@eof = false
|
||||||
@ -246,6 +246,7 @@ class Reline::LineEditor
|
|||||||
@buffer_of_lines.insert(@line_index + 1, String.new(next_line, encoding: @encoding))
|
@buffer_of_lines.insert(@line_index + 1, String.new(next_line, encoding: @encoding))
|
||||||
@previous_line_index = @line_index
|
@previous_line_index = @line_index
|
||||||
@line_index += 1
|
@line_index += 1
|
||||||
|
@just_cursor_moving = false
|
||||||
end
|
end
|
||||||
|
|
||||||
private def calculate_height_by_width(width)
|
private def calculate_height_by_width(width)
|
||||||
@ -923,6 +924,7 @@ class Reline::LineEditor
|
|||||||
end
|
end
|
||||||
|
|
||||||
def input_key(key)
|
def input_key(key)
|
||||||
|
@just_cursor_moving = nil
|
||||||
if key.char.nil?
|
if key.char.nil?
|
||||||
if @first_char
|
if @first_char
|
||||||
@line = nil
|
@line = nil
|
||||||
@ -958,12 +960,16 @@ class Reline::LineEditor
|
|||||||
unless completion_occurs
|
unless completion_occurs
|
||||||
@completion_state = CompletionState::NORMAL
|
@completion_state = CompletionState::NORMAL
|
||||||
end
|
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
|
if @previous_line_index and @buffer_of_lines[@previous_line_index] == @line
|
||||||
@just_cursor_moving = true
|
@just_cursor_moving = true
|
||||||
elsif @previous_line_index.nil? and @buffer_of_lines[@line_index] == @line
|
elsif @previous_line_index.nil? and @buffer_of_lines[@line_index] == @line
|
||||||
@just_cursor_moving = true
|
@just_cursor_moving = true
|
||||||
|
else
|
||||||
|
@just_cursor_moving = false
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
@just_cursor_moving = false
|
||||||
end
|
end
|
||||||
if @is_multiline and @auto_indent_proc and not simplified_rendering?
|
if @is_multiline and @auto_indent_proc and not simplified_rendering?
|
||||||
process_auto_indent
|
process_auto_indent
|
||||||
|
@ -373,6 +373,19 @@ begin
|
|||||||
EOC
|
EOC
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_foced_newline_insertion
|
||||||
|
start_terminal(10, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}, startup_message: 'Multiline REPL.')
|
||||||
|
#write("def a\nend\C-p\C-e\e\C-m 3")
|
||||||
|
write("def a\nend\C-p\C-e\e\x0D")
|
||||||
|
close
|
||||||
|
assert_screen(<<~EOC)
|
||||||
|
Multiline REPL.
|
||||||
|
prompt> def a
|
||||||
|
prompt>
|
||||||
|
prompt> end
|
||||||
|
EOC
|
||||||
|
end
|
||||||
|
|
||||||
def test_multiline_incremental_search
|
def test_multiline_incremental_search
|
||||||
start_terminal(6, 25, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}, startup_message: 'Multiline REPL.')
|
start_terminal(6, 25, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}, startup_message: 'Multiline REPL.')
|
||||||
write("def a\n 8\nend\ndef b\n 3\nend\C-s8")
|
write("def a\n 8\nend\ndef b\n 3\nend\C-s8")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user