forked from qt-creator/qt-creator
qmljs: use IEditor to positioning cursor after reformat
Thanks to the IEditor interface, there is no more need to use the editor's widget. Change-Id: Ic316dd21572ec5c36e10c9213a6c5d19bd7c62e6 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -273,13 +273,12 @@ void QmlJSEditorPlugin::reformatFile()
|
|||||||
tc.insertText(newText);
|
tc.insertText(newText);
|
||||||
};
|
};
|
||||||
|
|
||||||
QmlJSEditorWidget *widget = EditorManager::currentEditor()
|
IEditor *ed = EditorManager::currentEditor();
|
||||||
? qobject_cast<QmlJSEditorWidget*>(EditorManager::currentEditor()->widget())
|
if (ed) {
|
||||||
: nullptr;
|
int line = ed->currentLine();
|
||||||
if (widget) {
|
int column = ed->currentColumn();
|
||||||
const int position = widget->position();
|
|
||||||
setNewText();
|
setNewText();
|
||||||
widget->setCursorPosition(position);
|
ed->gotoLine(line, column);
|
||||||
} else {
|
} else {
|
||||||
setNewText();
|
setNewText();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user