Skip to content

Commit 600a9ea

Browse files
committed
Fix CSI pattern regexp to accept parameter bytes and intermediate bytes
1 parent 274850e commit 600a9ea

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/reline/unicode.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Reline::Unicode
3737

3838
NON_PRINTING_START = "\1"
3939
NON_PRINTING_END = "\2"
40-
CSI_REGEXP = /\e\[[\d;]*[ABCDEFGHJKSTfminsuhl]/
40+
CSI_REGEXP = /\e\[[\x30-\x3f]*[\x20-\x2f]*[a-zA-Z]/
4141
OSC_REGEXP = /\e\]\d+(?:;[^;\a\e]+)*(?:\a|\e\\)/
4242
WIDTH_SCANNER = /\G(?:(#{NON_PRINTING_START})|(#{NON_PRINTING_END})|(#{CSI_REGEXP})|(#{OSC_REGEXP})|(\X))/o
4343

test/reline/test_unicode.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_ambiguous_width
1919
end
2020

2121
def test_csi_regexp
22-
csi_sequences = ["\e[m", "\e[1m", "\e[12;34m", "\e[12;34H"]
22+
csi_sequences = ["\e[m", "\e[1m", "\e[12;34m", "\e[12;34H", "\e[5 q", "\e[?2004h"]
2323
assert_equal(csi_sequences, "text#{csi_sequences.join('text')}text".scan(Reline::Unicode::CSI_REGEXP))
2424
end
2525

0 commit comments

Comments
 (0)