Mon-Ouie/coolline — pull request #3 by kyrylo (2012-07-10 12:17:00+00:00)
Title: Fix AnsiCode regexp

This commit indirectly fixes issue #5 from
https://github.com/pry/pry-coolline/issues/5
(display issues when combined with pry-theme)

Words marked with square brackets an a number between them are my
notes.
-----------------------------------------------------------------------

Description by jperry:

When I have pry-theme[1] installed and using the railscasts theme[2] I
get some syntax i get some display issues, see below:

def test(a,b,c)
puts a,b,c
end

test("a","b","c

When I go to type double quotes and ')' after the "c" on the last line
it doesn't show up until I hit enter. When I disable coolline it works
without any issues.

-----------------------------------------------------------------------

Notable comment by me:

The problem is dependent on the width of a terminal. The more narrow
your terminal, the less you can see. Here are my results with your
example, with the width of the terminal of ~50 characters:

test("a #
^^ ^
|| `---- actual position of the cursor
|`- unseen quotation mark (rest of this line is invisible too)
|
`---- last visible character

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[1]: pry-theme is a plugin for Pry, which allows a user to use its own
color themes;

[2]: railscasts theme is a theme file for pry-theme plugin.
-----------------------------------------------------------------------

Fix incorrect AnsiCode Regexp and add some tests for it. The problem in
the old Regexp was the absence of square brackets around ";\d" symbols.
Thus, `Coolline#strip_ansi_codes` method stripped strings with advanced
color codes like in the example below:

strip_ansi_codes("\e[38;5;232mLove\e[0m")
#=> ";5;232mLove"

Expected result, obviously, would be "Love".

Reported-by: Jason Perry
Signed-off-by: Kyrylo Silin