forked from qt-creator/qt-creator
Center cursor when going from Design mode to text mode
Just use high level TextEditor::gotoLine instead of directly manipulating the QTextCursor. Task-number: BAUHAUS-326
This commit is contained in:
@@ -311,14 +311,15 @@ void DocumentWidget::setAutoSynchronization(bool sync)
|
|||||||
selectedNode = rewriter->selectedModelNodes().first();
|
selectedNode = rewriter->selectedModelNodes().first();
|
||||||
|
|
||||||
if (selectedNode.isValid()) {
|
if (selectedNode.isValid()) {
|
||||||
int nodeOffset = rewriter->nodeOffset(selectedNode);
|
const int nodeOffset = rewriter->nodeOffset(selectedNode);
|
||||||
QTextCursor editTextCursor = m_textBuffer->textCursor();
|
if (nodeOffset > 0) {
|
||||||
if (nodeOffset > 0
|
const ModelNode currentSelectedNode
|
||||||
&& nodeForPosition(editTextCursor.position()) != selectedNode) {
|
= nodeForPosition(m_textBuffer->textCursor().position());
|
||||||
if (debug)
|
if (currentSelectedNode != selectedNode) {
|
||||||
qDebug() << "Moving text cursor to " << nodeOffset;
|
int line, column;
|
||||||
editTextCursor.setPosition(nodeOffset);
|
textEditor()->convertPosition(nodeOffset, &line, &column);
|
||||||
m_textBuffer->setTextCursor(editTextCursor);
|
textEditor()->gotoLine(line, column);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user