From 32e444d9ccf521fd04f44bad4ec19c37890d6562 Mon Sep 17 00:00:00 2001 From: Marco Benelli Date: Fri, 13 Oct 2017 13:45:25 +0200 Subject: [PATCH] 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 --- src/plugins/qmljseditor/qmljseditorplugin.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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(); }