diff --git a/src/plugins/coreplugin/editormanager/documentmodel.cpp b/src/plugins/coreplugin/editormanager/documentmodel.cpp index f6fcee9d874..20712a9d79d 100644 --- a/src/plugins/coreplugin/editormanager/documentmodel.cpp +++ b/src/plugins/coreplugin/editormanager/documentmodel.cpp @@ -617,10 +617,10 @@ DocumentModel::Entry *DocumentModel::entryForDocument(IDocument *document) DocumentModel::Entry *DocumentModel::entryForFilePath(const Utils::FilePath &filePath) { - const Utils::optional index = d->indexOfFilePath(filePath); - if (!index) + if (filePath.isEmpty()) return nullptr; - return d->m_entries.at(*index); + const FilePath fixedPath = DocumentManager::filePathKey(filePath, DocumentManager::ResolveLinks); + return d->m_entryByFixedPath.value(fixedPath); } QList DocumentModel::openedDocuments() @@ -630,10 +630,8 @@ QList DocumentModel::openedDocuments() IDocument *DocumentModel::documentForFilePath(const Utils::FilePath &filePath) { - const Utils::optional index = d->indexOfFilePath(filePath); - if (!index) - return nullptr; - return d->m_entries.at(*index)->document; + const Entry *entry = entryForFilePath(filePath); + return entry ? entry->document : nullptr; } QList DocumentModel::editorsForFilePath(const Utils::FilePath &filePath)