[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
This commit is contained in:
parent
5c32a1503f
commit
cf24a0483e
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -38,6 +38,11 @@ class Reline::Unicode::Test < Reline::TestCase
|
||||
assert_equal [["ab\e]0;1\ac", nil, "\e]0;1\ad"], 2], Reline::Unicode.split_by_width("ab\e]0;1\acd", 3)
|
||||
end
|
||||
|
||||
def test_split_by_width_csi_reset_sgr_optimization
|
||||
assert_equal [["\e[1ma\e[mb\e[2mc", nil, "\e[2md\e[0me\e[3mf", nil, "\e[3mg"], 3], Reline::Unicode.split_by_width("\e[1ma\e[mb\e[2mcd\e[0me\e[3mfg", 3)
|
||||
assert_equal [["\e[1ma\1\e[mzero\e[0m\2\e[2mb", nil, "\e[1m\e[2mc"], 2], Reline::Unicode.split_by_width("\e[1ma\1\e[mzero\e[0m\2\e[2mbc", 2)
|
||||
end
|
||||
|
||||
def test_take_range
|
||||
assert_equal 'cdef', Reline::Unicode.take_range('abcdefghi', 2, 4)
|
||||
assert_equal 'あde', Reline::Unicode.take_range('abあdef', 2, 4)
|
||||
|
Loading…
x
Reference in New Issue
Block a user