diff options
author | tomoya ishida <tomoyapenguin@gmail.com> | 2024-04-25 02:33:36 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2024-04-24 17:33:40 +0000 |
commit | cf24a0483e5ae0730c17dcb784122419a937cb17 (patch) | |
tree | f49f4a3b5757f40eb4ea608e2ff09d3e6a39e1e1 /lib | |
parent | 5c32a1503f332dfece617bdf7e7f6a4d5f28977a (diff) |
[ruby/reline] Long line performance
(https://github.com/ruby/reline/pull/688)
* Improve C-e (ed_move_to_end) performance for long line
* Reline::Unicode.split_by_width optimization for RESET_SGR
https://github.com/ruby/reline/commit/0c8d3c827a
Diffstat (limited to 'lib')
-rw-r--r-- | lib/reline/line_editor.rb | 6 | ||||
-rw-r--r-- | lib/reline/unicode.rb | 8 |
2 files changed, 8 insertions, 6 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 686a101869..81413505d7 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -1542,11 +1542,7 @@ class Reline::LineEditor alias_method :vi_zero, :ed_move_to_beg private def ed_move_to_end(key) - @byte_pointer = 0 - while @byte_pointer < current_line.bytesize - byte_size = Reline::Unicode.get_next_mbchar_size(current_line, @byte_pointer) - @byte_pointer += byte_size - end + @byte_pointer = current_line.bytesize end alias_method :end_of_line, :ed_move_to_end diff --git a/lib/reline/unicode.rb b/lib/reline/unicode.rb index 1a916b4b98..7f94e95287 100644 --- a/lib/reline/unicode.rb +++ b/lib/reline/unicode.rb @@ -145,7 +145,13 @@ class Reline::Unicode lines.last << NON_PRINTING_END when csi lines.last << csi - seq << csi + unless in_zero_width + if csi == -"\e[m" || csi == -"\e[0m" + seq.clear + else + seq << csi + end + end when osc lines.last << osc seq << osc |