about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/ext/widestring.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/ranger/ext/widestring.py b/ranger/ext/widestring.py
index 44972c9c..fbd84b0d 100644
--- a/ranger/ext/widestring.py
+++ b/ranger/ext/widestring.py
@@ -88,6 +88,8 @@ class WideString(object):
 		"""
 		>>> WideString("asdf")[1:3]
 		<WideString 'sd'>
+		>>> WideString("asdf")[1:-100]
+		<WideString ''>
 		>>> WideString("モヒカン")[2:4]
 		<WideString 'ヒ'>
 		>>> WideString("モヒカン")[2:5]
@@ -107,6 +109,10 @@ class WideString(object):
 		"""
 		if z is None or z > len(self.chars):
 			z = len(self.chars)
+		if z < 0:
+			z = len(self.chars) + z
+		if z < 0:
+			return WideString("")
 		if a is None or a < 0:
 			a = 0
 		if z < len(self.chars) and self.chars[z] == '':
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114