diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp index efc7d4fec7c..068fbb4340b 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.cpp +++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp @@ -273,13 +273,12 @@ void QmlJSEditorPlugin::reformatFile() tc.insertText(newText); }; - QmlJSEditorWidget *widget = EditorManager::currentEditor() - ? qobject_cast(EditorManager::currentEditor()->widget()) - : nullptr; - if (widget) { - const int position = widget->position(); + IEditor *ed = EditorManager::currentEditor(); + if (ed) { + int line = ed->currentLine(); + int column = ed->currentColumn(); setNewText(); - widget->setCursorPosition(position); + ed->gotoLine(line, column); } else { setNewText(); }