Use first root .tex file as fallback main doc when importing from zip (#24302)

GitOrigin-RevId: 51affe14b77aa4f774d5e5f0807f42e07842f807
This commit is contained in:
Alf Eaton
2025-03-19 09:31:32 +00:00
committed by Copybot
parent 67a6857ca6
commit d7cddd14fa
2 changed files with 74 additions and 13 deletions
@@ -113,6 +113,7 @@ module.exports = ProjectRootDocManager = {
if (err != null) {
return callback(err)
}
let firstFileInRootFolder
let doc = null
return async.until(
@@ -130,16 +131,26 @@ module.exports = ProjectRootDocManager = {
if (DocumentHelper.contentHasDocumentclass(content)) {
doc = { path: file, content }
}
return cb(null)
if (!firstFileInRootFolder && !file.includes('/')) {
firstFileInRootFolder = { path: file, content }
}
cb(null)
}
)
},
err =>
callback(
err,
doc != null ? doc.path : undefined,
doc != null ? doc.content : undefined
)
err => {
if (err) {
return callback(err)
}
// if no doc was found, use the first file in the root folder as the main doc
if (!doc && firstFileInRootFolder) {
doc = firstFileInRootFolder
}
callback(null, doc?.path, doc?.content)
}
)
}
),