diff options
-rw-r--r-- | ranger/ext/widestring.py | 6 |
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] == '': |