forked from qt-creator/qt-creator
Core: move the fileName line column parsing of openEditor
Move it from EditorManagerPrivate::openEditor to the EditorManager::openEditor overlaod that take a QString so no line or column number should be passed via FilePath now. Change-Id: Ia98058195045cbe555fb6a15c1010057746051d8 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -789,23 +789,10 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const FilePath &file
|
|||||||
if (debugEditorManager)
|
if (debugEditorManager)
|
||||||
qDebug() << Q_FUNC_INFO << filePath << editorId.name();
|
qDebug() << Q_FUNC_INFO << filePath << editorId.name();
|
||||||
|
|
||||||
QString fn = filePath.toString();
|
const QString fn = Utils::FileUtils::normalizePathName(filePath.toString());
|
||||||
QFileInfo fi(fn);
|
|
||||||
int lineNumber = -1;
|
|
||||||
int columnNumber = -1;
|
|
||||||
if ((flags & EditorManager::CanContainLineAndColumnNumber) && !fi.exists()) {
|
|
||||||
Link link = Link::fromString(fn, true);
|
|
||||||
fn = Utils::FileUtils::normalizePathName(link.targetFilePath.toString());
|
|
||||||
lineNumber = link.targetLine;
|
|
||||||
columnNumber = link.targetColumn;
|
|
||||||
} else {
|
|
||||||
fn = Utils::FileUtils::normalizePathName(fn);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fn.isEmpty())
|
if (fn.isEmpty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if (fn != filePath.toString())
|
const QFileInfo fi(fn);
|
||||||
fi.setFile(fn);
|
|
||||||
|
|
||||||
if (newEditor)
|
if (newEditor)
|
||||||
*newEditor = false;
|
*newEditor = false;
|
||||||
@@ -824,10 +811,7 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const FilePath &file
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
editor = activateEditor(view, editor, flags);
|
return activateEditor(view, editor, flags);
|
||||||
if (editor && flags & EditorManager::CanContainLineAndColumnNumber)
|
|
||||||
editor->gotoLine(lineNumber, columnNumber);
|
|
||||||
return editor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString realFn = autoSaveName(fn);
|
QString realFn = autoSaveName(fn);
|
||||||
@@ -947,9 +931,6 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const FilePath &file
|
|||||||
if (editor == result)
|
if (editor == result)
|
||||||
restoreEditorState(editor);
|
restoreEditorState(editor);
|
||||||
|
|
||||||
if (flags & EditorManager::CanContainLineAndColumnNumber)
|
|
||||||
editor->gotoLine(lineNumber, columnNumber);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3090,6 +3071,9 @@ IEditor *EditorManager::openEditor(const FilePath &filePath, Id editorId,
|
|||||||
IEditor *EditorManager::openEditor(const QString &fileName, Id editorId,
|
IEditor *EditorManager::openEditor(const QString &fileName, Id editorId,
|
||||||
OpenEditorFlags flags, bool *newEditor)
|
OpenEditorFlags flags, bool *newEditor)
|
||||||
{
|
{
|
||||||
|
QFileInfo fi(fileName);
|
||||||
|
if ((flags & CanContainLineAndColumnNumber) && !fi.exists())
|
||||||
|
return openEditorAt(Link::fromString(fileName, true), editorId, flags, newEditor);
|
||||||
return openEditor(FilePath::fromString(fileName), editorId, flags, newEditor);
|
return openEditor(FilePath::fromString(fileName), editorId, flags, newEditor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user