diff options
author | tomoya ishida <tomoyapenguin@gmail.com> | 2023-03-29 15:54:03 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-03-29 06:54:08 +0000 |
commit | e26908dc4b6604cfe3c89f4cdc75dab67dff7d03 (patch) | |
tree | ecd6967e12a6281a4c1a996247b0e58a132c9b16 /test/reline | |
parent | 8c8d0680161c9671e68303ee2b27ccbea4bd293a (diff) | |
download | ruby-e26908dc4b6604cfe3c89f4cdc75dab67dff7d03.tar.gz |
[ruby/reline] Improve OSC sequence regexp. OSC sequence can end with
ST(ESC\) and it should not to include \a and \e inside.
(https://github.com/ruby/reline/pull/527)
https://github.com/ruby/reline/commit/a88052adec
Diffstat (limited to 'test/reline')
-rw-r--r-- | test/reline/test_unicode.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/reline/test_unicode.rb b/test/reline/test_unicode.rb index ee8e72c0d4..834f7114c4 100644 --- a/test/reline/test_unicode.rb +++ b/test/reline/test_unicode.rb @@ -18,6 +18,17 @@ class Reline::Unicode::Test < Reline::TestCase assert_equal 2, Reline::Unicode.calculate_width('√', true) end + def test_csi_regexp + csi_sequences = ["\e[m", "\e[1m", "\e[12;34m", "\e[12;34H"] + assert_equal(csi_sequences, "text#{csi_sequences.join('text')}text".scan(Reline::Unicode::CSI_REGEXP)) + end + + def test_osc_regexp + osc_sequences = ["\e]1\a", "\e]0;OSC\a", "\e]1\e\\", "\e]0;OSC\e\\"] + separator = "text\atext" + assert_equal(osc_sequences, "#{separator}#{osc_sequences.join(separator)}#{separator}".scan(Reline::Unicode::OSC_REGEXP)) + end + def test_split_by_width assert_equal [['abc', nil, 'de'], 2], Reline::Unicode.split_by_width('abcde', 3) assert_equal [['abc', nil, 'def', nil, ''], 3], Reline::Unicode.split_by_width('abcdef', 3) |