I want to put the cursor at the start of a line in a QPlainTextEdit
specified by its line number. The problem is I have the "real" line number, i.e. the number of \n
between the line and the start, while the cursor seems to be using "virtual" line numbers, i.e. including the line wraps done by the textedit.
Which means that the following does not work correctly:
old_line = textedit.textCursor().blockNumber()
line = token.line
diff = line - old_line
move = QtGui.QTextCursor.Down if diff >= 0 else QtGui.QTextCursor.Up
for _ in range(abs(diff)): textedit.moveCursor(move, QtGui.QTextCursor.MoveAnchor)