mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #13016 from overleaf/dk-syncToEntry-detached
fix: navigate to error location for detached PDF mode GitOrigin-RevId: 238f163f961e23e57d170180f918d8106b05c23e
This commit is contained in:
parent
5fd4504f51
commit
0bfd1fc852
3 changed files with 29 additions and 27 deletions
|
@ -1,39 +1,15 @@
|
||||||
import { memo, useCallback } from 'react'
|
import { memo } from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import PreviewLogsPaneMaxEntries from '../../preview/components/preview-logs-pane-max-entries'
|
import PreviewLogsPaneMaxEntries from '../../preview/components/preview-logs-pane-max-entries'
|
||||||
import PdfLogEntry from './pdf-log-entry'
|
import PdfLogEntry from './pdf-log-entry'
|
||||||
import { useIdeContext } from '../../../shared/context/ide-context'
|
import { useDetachCompileContext } from '../../../shared/context/detach-compile-context'
|
||||||
import useDetachAction from '../../../shared/hooks/use-detach-action'
|
|
||||||
|
|
||||||
const LOG_PREVIEW_LIMIT = 100
|
const LOG_PREVIEW_LIMIT = 100
|
||||||
|
|
||||||
function PdfLogsEntries({ entries, hasErrors }) {
|
function PdfLogsEntries({ entries, hasErrors }) {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
const { syncToEntry } = useDetachCompileContext()
|
||||||
const ide = useIdeContext()
|
|
||||||
|
|
||||||
const _syncToEntry = useCallback(
|
|
||||||
entry => {
|
|
||||||
const entity = ide.fileTreeManager.findEntityByPath(entry.file)
|
|
||||||
|
|
||||||
if (entity && entity.type === 'doc') {
|
|
||||||
ide.editorManager.openDoc(entity, {
|
|
||||||
gotoLine: entry.line ?? undefined,
|
|
||||||
gotoColumn: entry.column ?? undefined,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[ide]
|
|
||||||
)
|
|
||||||
|
|
||||||
const syncToEntry = useDetachAction(
|
|
||||||
'sync-to-entry',
|
|
||||||
_syncToEntry,
|
|
||||||
'detached',
|
|
||||||
'detacher'
|
|
||||||
)
|
|
||||||
|
|
||||||
const logEntries = entries.slice(0, LOG_PREVIEW_LIMIT)
|
const logEntries = entries.slice(0, LOG_PREVIEW_LIMIT)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -72,6 +72,7 @@ export function DetachCompileProvider({ children }) {
|
||||||
setChangedAt: _setChangedAt,
|
setChangedAt: _setChangedAt,
|
||||||
setSavedAt: _setSavedAt,
|
setSavedAt: _setSavedAt,
|
||||||
clearCache: _clearCache,
|
clearCache: _clearCache,
|
||||||
|
syncToEntry: _syncToEntry,
|
||||||
} = localCompileContext
|
} = localCompileContext
|
||||||
|
|
||||||
const [animateCompileDropdownArrow] = useDetachStateWatcher(
|
const [animateCompileDropdownArrow] = useDetachStateWatcher(
|
||||||
|
@ -366,6 +367,13 @@ export function DetachCompileProvider({ children }) {
|
||||||
'detacher'
|
'detacher'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const syncToEntry = useDetachAction(
|
||||||
|
'sync-to-entry',
|
||||||
|
_syncToEntry,
|
||||||
|
'detached',
|
||||||
|
'detacher'
|
||||||
|
)
|
||||||
|
|
||||||
useCompileTriggers(startCompile, setChangedAt, setSavedAt)
|
useCompileTriggers(startCompile, setChangedAt, setSavedAt)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Sync the split test variant across the editor and pdf-detach.
|
// Sync the split test variant across the editor and pdf-detach.
|
||||||
|
@ -426,6 +434,7 @@ export function DetachCompileProvider({ children }) {
|
||||||
firstRenderDone,
|
firstRenderDone,
|
||||||
setChangedAt,
|
setChangedAt,
|
||||||
cleanupCompileResult,
|
cleanupCompileResult,
|
||||||
|
syncToEntry,
|
||||||
}),
|
}),
|
||||||
[
|
[
|
||||||
animateCompileDropdownArrow,
|
animateCompileDropdownArrow,
|
||||||
|
@ -477,6 +486,7 @@ export function DetachCompileProvider({ children }) {
|
||||||
firstRenderDone,
|
firstRenderDone,
|
||||||
setChangedAt,
|
setChangedAt,
|
||||||
cleanupCompileResult,
|
cleanupCompileResult,
|
||||||
|
syncToEntry,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -522,6 +522,20 @@ export function LocalCompileProvider({ children }) {
|
||||||
})
|
})
|
||||||
}, [compiler])
|
}, [compiler])
|
||||||
|
|
||||||
|
const syncToEntry = useCallback(
|
||||||
|
entry => {
|
||||||
|
const entity = ide.fileTreeManager.findEntityByPath(entry.file)
|
||||||
|
|
||||||
|
if (entity && entity.type === 'doc') {
|
||||||
|
ide.editorManager.openDoc(entity, {
|
||||||
|
gotoLine: entry.line ?? undefined,
|
||||||
|
gotoColumn: entry.column ?? undefined,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[ide]
|
||||||
|
)
|
||||||
|
|
||||||
// clear the cache then run a compile, triggered by a menu item
|
// clear the cache then run a compile, triggered by a menu item
|
||||||
const recompileFromScratch = useCallback(() => {
|
const recompileFromScratch = useCallback(() => {
|
||||||
clearCache().then(() => {
|
clearCache().then(() => {
|
||||||
|
@ -587,6 +601,7 @@ export function LocalCompileProvider({ children }) {
|
||||||
setChangedAt,
|
setChangedAt,
|
||||||
setSavedAt,
|
setSavedAt,
|
||||||
cleanupCompileResult,
|
cleanupCompileResult,
|
||||||
|
syncToEntry,
|
||||||
}),
|
}),
|
||||||
[
|
[
|
||||||
animateCompileDropdownArrow,
|
animateCompileDropdownArrow,
|
||||||
|
@ -638,6 +653,7 @@ export function LocalCompileProvider({ children }) {
|
||||||
cleanupCompileResult,
|
cleanupCompileResult,
|
||||||
setShowLogs,
|
setShowLogs,
|
||||||
toggleLogs,
|
toggleLogs,
|
||||||
|
syncToEntry,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue