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:
Marco Benelli
2017-10-13 13:45:25 +02:00
parent 267167a097
commit 32e444d9cc

View File

@@ -273,13 +273,12 @@ void QmlJSEditorPlugin::reformatFile()
tc.insertText(newText);
};
QmlJSEditorWidget *widget = EditorManager::currentEditor()
? qobject_cast<QmlJSEditorWidget*>(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();
}