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);
|
||||
};
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user