diff options
author | hut <hut@lavabit.com> | 2011-10-11 21:29:48 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2011-10-11 21:29:48 +0200 |
commit | 11c246d5e1f9be9fc7bfe429e8ce2ff2e972cb05 (patch) | |
tree | 68e05c7954300870a2eaf0df1712dbc3b6676b71 | |
parent | 9b05f8d7279266c1b1ed2224d9a33f67935f2586 (diff) | |
download | ranger-11c246d5e1f9be9fc7bfe429e8ce2ff2e972cb05.tar.gz |
gui.ansi: Added another test case
-rw-r--r-- | ranger/gui/ansi.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/ranger/gui/ansi.py b/ranger/gui/ansi.py index 802df04d..5fce557a 100644 --- a/ranger/gui/ansi.py +++ b/ranger/gui/ansi.py @@ -101,6 +101,8 @@ def char_slice(ansi_text, start, length): '\\x1b[0mnormal' >>> char_slice(test_string, 9, 100) '\\x1b[31mar\\x1b[0mnormal' + >>> char_slice(test_string, 9, 4) + '\\x1b[31mar\\x1b[0mno' """ chunks = [] last_color = "" @@ -115,6 +117,11 @@ def char_slice(ansi_text, start, length): chunks.append(last_color) chunks.append(chunk[start-pos:start-pos+length]) pos += len(chunk) + elif pos + len(chunk) - start > length: + if chunk[:start-pos+length]: + chunks.append(last_color) + chunks.append(chunk[:start-pos+length]) + pos += len(chunk) else: chunks.append(last_color) chunks.append(chunk) |