Skip to content

Commit

Permalink
[fix] Readline fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fazibear committed Jun 19, 2023
1 parent 4498bb6 commit f579f09
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/colorize/instance_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def mode(mode)
# Scan for colorized string
#
def scan_for_colors
scan(/\001\033\[([0-9;]+)m\002(.+?)\001\033\[0m\002|([^\001\033]+)/m).map do |match|
scan(/\001?\033\[([0-9;]+)m\002?(.+?)\001?\033\[0m\002?|([^\001?\033]+)/m).map do |match|
split_colors(match)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/colorize/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# Gem version
#
module Colorize
VERSION = '1.0.0'
VERSION = '1.0.1'
end
4 changes: 4 additions & 0 deletions test/test_colorize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,8 @@ def test_prevent_colors

String.prevent_colors false
end

def test_colorized_string_without_readline
assert_equal "\e[0;31;49mgreen\e[0m".green, 'green'.green
end
end
4 changes: 4 additions & 0 deletions test/test_colorized_string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,8 @@ def test_prevent_colors

ColorizedString.prevent_colors false
end

def test_colorized_string_without_readline
assert_equal ColorizedString["\e[0;31;49mgreen\e[0m"].green, ColorizedString['green'].green
end
end

0 comments on commit f579f09

Please sign in to comment.