Skip to content
Snippets Groups Projects
Commit 53fb9d4a authored by Robert Loehning's avatar Robert Loehning Committed by Robert Löhning
Browse files

Squish: Simplified placeCursorToLine


Change-Id: Ib56bc7b2596ac61233e147fb62f763a594abe9df
Reviewed-by: default avatarChristian Stenger <christian.stenger@nokia.com>
parent a71b7686
No related branches found
No related tags found
No related merge requests found
......@@ -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, "<Down>")
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment