fix for renderedSubStr going past str len
@@ -346,8 +346,12 @@ def renderedSubStr(string, beginCol, endCol):
endIndex = sys.maxsize
i = 0
limit = len(string)
- while i <= limit:
- if beginCol <= column:
+ while column < beginCol:
+ if i >= limit:
+ # The |string| is entirely before |beginCol|.
+ return u""
+ column += 2 if string[i] >= MIN_DOUBLE_WIDE_CHARACTER else 1
+ i += 1
if beginCol == column:
# An exact (aligned) trimming (not splitting a double-wide
# character).
@@ -364,9 +368,6 @@ def renderedSubStr(string, beginCol, endCol):
limit += 1
column = 1
i = 1
- break
- column += 2 if string[i] >= MIN_DOUBLE_WIDE_CHARACTER else 1
- i += 1
while True:
if endCol <= column:
if endCol == column:
