diff options
author | tomoya ishida <[email protected]> | 2024-12-10 19:28:16 +0900 |
---|---|---|
committer | git <[email protected]> | 2024-12-10 10:28:22 +0000 |
commit | 3568e7aef7ace192297693deb770c10928ade314 (patch) | |
tree | a7e1eec37893810066f2ad1a21b7261a0bb65c37 /lib | |
parent | ebb80c26b34525eb5630e17e195313943acc421c (diff) |
[ruby/reline] Fix line wrapped cursor position
(https://github.com/ruby/reline/pull/791)
Cursor position calculation was wrong when the input line contains "\1" or CSI escape sequence.
https://github.com/ruby/reline/commit/a1943daaf4
Diffstat (limited to 'lib')
-rw-r--r-- | lib/reline/line_editor.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 0ba44f8bc6..86c7596df7 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -436,7 +436,7 @@ class Reline::LineEditor # Calculate cursor position in word wrapped content. def wrapped_cursor_position prompt_width = calculate_width(prompt_list[@line_index], true) - line_before_cursor = whole_lines[@line_index].byteslice(0, @byte_pointer) + line_before_cursor = Reline::Unicode.escape_for_print(whole_lines[@line_index].byteslice(0, @byte_pointer)) wrapped_line_before_cursor = split_line_by_width(' ' * prompt_width + line_before_cursor, screen_width) wrapped_cursor_y = wrapped_prompt_and_input_lines[0...@line_index].sum(&:size) + wrapped_line_before_cursor.size - 1 wrapped_cursor_x = calculate_width(wrapped_line_before_cursor.last) |