diff options
author | aycabta <aycabta@gmail.com> | 2020-09-09 19:46:30 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2020-09-12 08:35:52 +0900 |
commit | 0ec19cc8435fb3f04c503af374942a2ea74b0e46 (patch) | |
tree | bab138489c4c7172ef0824e9a2f867b4b15199fa /lib | |
parent | 2e34b35a0ff7c326d1260a7f4dd3e4a9febe3d12 (diff) | |
download | ruby-0ec19cc8435fb3f04c503af374942a2ea74b0e46.tar.gz |
[ruby/reline] Stop erasing chars after the cursor at eol
When the cursor is at the end of the line and erases characters after the
cursor, some terminals delete the character at the cursor position.
https://github.com/ruby/reline/commit/e96ec97b02
Diffstat (limited to 'lib')
-rw-r--r-- | lib/reline/line_editor.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index b4d2b457c7..fe088a4721 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -492,8 +492,18 @@ class Reline::LineEditor Reline::IOGate.move_cursor_column(0) visual_lines.each_with_index do |line, index| if line.nil? - if Reline::IOGate.win? and calculate_width(visual_lines[index - 1], true) == Reline::IOGate.get_screen_size.last - # A newline is automatically inserted if a character is rendered at eol on command prompt. + if calculate_width(visual_lines[index - 1], true) == Reline::IOGate.get_screen_size.last + # reaches the end of line + if Reline::IOGate.win? + # A newline is automatically inserted if a character is rendered at + # eol on command prompt. + else + # When the cursor is at the end of the line and erases characters + # after the cursor, some terminals delete the character at the + # cursor position. + move_cursor_down(1) + Reline::IOGate.move_cursor_column(0) + end else Reline::IOGate.erase_after_cursor move_cursor_down(1) |