mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #15804 from overleaf/td-compile-log-links
Fix bug with compile log links GitOrigin-RevId: fc10b6dcd09ba36fb358fbd1a13012205d4f568d
This commit is contained in:
parent
86c06d8c99
commit
fa0ea24f53
2 changed files with 19 additions and 7 deletions
|
@ -19,7 +19,6 @@ export default class DocumentCompiler {
|
|||
constructor({
|
||||
compilingRef,
|
||||
projectId,
|
||||
rootDocId,
|
||||
setChangedAt,
|
||||
setSavedAt,
|
||||
setCompiling,
|
||||
|
@ -32,7 +31,6 @@ export default class DocumentCompiler {
|
|||
}) {
|
||||
this.compilingRef = compilingRef
|
||||
this.projectId = projectId
|
||||
this.rootDocId = rootDocId
|
||||
this.setChangedAt = setChangedAt
|
||||
this.setSavedAt = setSavedAt
|
||||
this.setCompiling = setCompiling
|
||||
|
@ -43,6 +41,7 @@ export default class DocumentCompiler {
|
|||
this.cleanupCompileResult = cleanupCompileResult
|
||||
this.signal = signal
|
||||
|
||||
this.projectRootDocId = null
|
||||
this.clsiServerId = null
|
||||
this.currentDoc = null
|
||||
this.error = undefined
|
||||
|
@ -95,8 +94,10 @@ export default class DocumentCompiler {
|
|||
|
||||
const t0 = performance.now()
|
||||
|
||||
const rootDocId = this.getRootDocOverrideId()
|
||||
|
||||
const body = {
|
||||
rootDoc_id: this.getRootDocOverrideId(),
|
||||
rootDoc_id: rootDocId,
|
||||
draft: options.draft,
|
||||
check: 'silent', // NOTE: 'error' and 'validate' are possible, but unused
|
||||
// use incremental compile for all users but revert to a full compile
|
||||
|
@ -123,6 +124,7 @@ export default class DocumentCompiler {
|
|||
this.setError(undefined)
|
||||
|
||||
data.options = options
|
||||
data.rootDocId = rootDocId
|
||||
if (data.clsiServerId) {
|
||||
this.clsiServerId = data.clsiServerId
|
||||
}
|
||||
|
@ -140,7 +142,7 @@ export default class DocumentCompiler {
|
|||
// if it contains "\documentclass" then use this as the root doc
|
||||
getRootDocOverrideId() {
|
||||
// only override when not in the root doc itself
|
||||
if (this.currentDoc.doc_id !== this.rootDocId) {
|
||||
if (this.currentDoc.doc_id !== this.projectRootDocId) {
|
||||
const snapshot = this.currentDoc.getSnapshot()
|
||||
|
||||
if (snapshot && isMainFile(snapshot)) {
|
||||
|
|
|
@ -144,6 +144,11 @@ export function LocalCompileProvider({ children }) {
|
|||
// data received in response to a compile request
|
||||
const [data, setData] = useState()
|
||||
|
||||
// the rootDocId used in the most recent compile request, which may not be the
|
||||
// same as the project rootDocId. This is used to calculate correct paths when
|
||||
// parsing the compile logs
|
||||
const lastCompileRootDocId = data?.rootDocId
|
||||
|
||||
// callback to be invoked for PdfJsMetrics
|
||||
const [firstRenderDone, setFirstRenderDone] = useState(() => () => {})
|
||||
|
||||
|
@ -251,8 +256,9 @@ export function LocalCompileProvider({ children }) {
|
|||
}, [compiling])
|
||||
|
||||
const _buildLogEntryAnnotations = useCallback(
|
||||
entries => buildLogEntryAnnotations(entries, fileTreeData, rootDocId),
|
||||
[fileTreeData, rootDocId]
|
||||
entries =>
|
||||
buildLogEntryAnnotations(entries, fileTreeData, lastCompileRootDocId),
|
||||
[fileTreeData, lastCompileRootDocId]
|
||||
)
|
||||
|
||||
const buildLogEntryAnnotationsRef = useRef(_buildLogEntryAnnotations)
|
||||
|
@ -265,7 +271,6 @@ export function LocalCompileProvider({ children }) {
|
|||
const [compiler] = useState(() => {
|
||||
return new DocumentCompiler({
|
||||
projectId,
|
||||
rootDocId,
|
||||
setChangedAt,
|
||||
setSavedAt,
|
||||
setCompiling,
|
||||
|
@ -284,6 +289,11 @@ export function LocalCompileProvider({ children }) {
|
|||
compiler.currentDoc = currentDoc
|
||||
}, [compiler, currentDoc])
|
||||
|
||||
// keep the project rootDocId in sync with the compiler
|
||||
useEffect(() => {
|
||||
compiler.projectRootDocId = rootDocId
|
||||
}, [compiler, rootDocId])
|
||||
|
||||
// keep draft setting in sync with the compiler
|
||||
useEffect(() => {
|
||||
compiler.setOption('draft', draft)
|
||||
|
|
Loading…
Reference in a new issue