summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2013-02-05 06:06:36 +0100
committerhut <hut@lavabit.com>2013-02-05 06:06:36 +0100
commit8e0e42a540d74c1f04d5497278099bce049a261d (patch)
tree26db5bcb57cf8aef78465937b09f0096586d1fe0
parent151ff73951af08a7d5611c22ce25f095feda3c6b (diff)
downloadranger-8e0e42a540d74c1f04d5497278099bce049a261d.tar.gz
ext.widestring: Fix corner case (bug #32687)
https://savannah.nongnu.org/bugs/index.php?32687
-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] == '':