From 4d647238b3c258a9b79326781f90c13a3745223f Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Fri, 31 May 2019 11:18:49 +0200 Subject: [PATCH] Fix sith.py line number generation --- sith.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sith.py b/sith.py index c2367663..17c6546c 100755 --- a/sith.py +++ b/sith.py @@ -111,7 +111,13 @@ class TestCase(object): if not lines: lines = [''] line = random.randint(1, len(lines)) - column = random.randint(0, len(lines[line - 1])) + line_string = lines[line - 1] + line_len = len(line_string) + if line_string.endswith('\r\n'): + line_len -= 1 + if line_string.endswith('\n'): + line_len -= 1 + column = random.randint(0, line_len) return cls(operation, path, line, column) def run(self, debugger, record=None, print_result=False):