diff --git a/tests/system/shared/editor_utils.py b/tests/system/shared/editor_utils.py index 2ebf8205f99..ae5fc8cfde6 100644 --- a/tests/system/shared/editor_utils.py +++ b/tests/system/shared/editor_utils.py @@ -5,7 +5,7 @@ import re; # and goes to the end of the line # line can be a regex - but if so, remember to set isRegex to True # the function returns True if this went fine, False on error -def placeCursorToLine(editor,line,isRegex=False): +def placeCursorToLine(editor, line, isRegex=False): cursor = editor.textCursor() oldPosition = 0 cursor.setPosition(oldPosition) @@ -15,26 +15,17 @@ def placeCursorToLine(editor,line,isRegex=False): regex = re.compile(line) while not found: currentLine = str(lineUnderCursor(editor)).strip() - if isRegex: - if regex.match(currentLine): - found = True - else: - moveTextCursor(editor, QTextCursor.Down, QTextCursor.MoveAnchor) - if oldPosition==editor.textCursor().position(): - break - oldPosition = editor.textCursor().position() - else: - if currentLine==line: - found = True - else: - moveTextCursor(editor, QTextCursor.Down, QTextCursor.MoveAnchor) - if oldPosition==editor.textCursor().position(): - break - oldPosition = editor.textCursor().position() + found = isRegex and regex.match(currentLine) or not isRegex and currentLine == line + if not found: + type(editor, "") + newPosition = editor.textCursor().position() + if oldPosition == newPosition: + break + oldPosition = newPosition if not found: test.fatal("Couldn't find line matching\n\n%s\n\nLeaving test..." % line) return False - cursor=editor.textCursor() + cursor = editor.textCursor() cursor.movePosition(QTextCursor.EndOfLine, QTextCursor.MoveAnchor) editor.setTextCursor(cursor) return True