summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2011-10-11 21:29:48 +0200
committerhut <hut@lavabit.com>2011-10-11 21:29:48 +0200
commit11c246d5e1f9be9fc7bfe429e8ce2ff2e972cb05 (patch)
tree68e05c7954300870a2eaf0df1712dbc3b6676b71
parent9b05f8d7279266c1b1ed2224d9a33f67935f2586 (diff)
downloadranger-11c246d5e1f9be9fc7bfe429e8ce2ff2e972cb05.tar.gz
gui.ansi: Added another test case
-rw-r--r--ranger/gui/ansi.py7
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)
83ba ^
f07bb12f ^
34a60763 ^
c9383c72 ^

b3556b21 ^
62cd83ba ^
3e18db75 ^

c9383c72 ^
a614f048 ^
f07bb12f ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36