diff options
author | tomoya ishida <[email protected]> | 2023-03-27 22:54:05 +0900 |
---|---|---|
committer | git <[email protected]> | 2023-03-27 13:57:16 +0000 |
commit | 8f569d41cba4379b8d50d24fdf8c43f43bc3f1b8 (patch) | |
tree | d5cc70250a3dc6f1fbbbf02911f667feefc5d54f /lib/reline/line_editor.rb | |
parent | a2ff9423a1ecc4f2831a69f82a60f00c4a3f81a9 (diff) |
[ruby/reline] Fix cursor position overrun
(https://github.com/ruby/reline/pull/515)
* Fix cursor position overrun
* Remove unnecessary local variable
Co-authored-by: Stan Lo <[email protected]>
---------
https://github.com/ruby/reline/commit/d4ad9b96c8
Co-authored-by: Stan Lo <[email protected]>
Diffstat (limited to 'lib/reline/line_editor.rb')
-rw-r--r-- | lib/reline/line_editor.rb | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index bd2f2c858a..cd6b1cd408 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -995,22 +995,18 @@ class Reline::LineEditor calculate_height_by_lines(@buffer_of_lines[0..(@line_index - 1)], prompt_list || prompt) end first_line_diff = new_first_line_started_from - @first_line_started_from - new_cursor, new_cursor_max, new_started_from, new_byte_pointer = calculate_nearest_cursor(@buffer_of_lines[@line_index], @cursor, @started_from, @byte_pointer, false) - new_started_from = calculate_height_by_width(prompt_width + new_cursor) - 1 + @cursor, @cursor_max, _, @byte_pointer = calculate_nearest_cursor(@buffer_of_lines[@line_index], @cursor, @started_from, @byte_pointer, false) + new_started_from = calculate_height_by_width(prompt_width + @cursor) - 1 calculate_scroll_partial_screen(@highest_in_all, new_first_line_started_from + new_started_from) @previous_line_index = nil + @line = @buffer_of_lines[@line_index] if @rerender_all - @line = @buffer_of_lines[@line_index] rerender_all_lines @rerender_all = false true else - @line = @buffer_of_lines[@line_index] @first_line_started_from = new_first_line_started_from @started_from = new_started_from - @cursor = new_cursor - @cursor_max = new_cursor_max - @byte_pointer = new_byte_pointer move_cursor_down(first_line_diff + @started_from) Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last) false |