mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-27 09:42:00 +00:00
Merge pull request #6039 from overleaf/ta-synctex-cursor-position-init
Fix Cursor Position Tracking for Synctex GitOrigin-RevId: 6df703812f3efa2163b953aab82f32e174919179
This commit is contained in:
parent
f7275a6c4b
commit
c1c0f1fe4a
1 changed files with 8 additions and 2 deletions
|
@ -14,6 +14,7 @@ import useIsMounted from '../../../shared/hooks/use-is-mounted'
|
|||
import useAbortController from '../../../shared/hooks/use-abort-controller'
|
||||
import useDetachState from '../../../shared/hooks/use-detach-state'
|
||||
import useDetachAction from '../../../shared/hooks/use-detach-action'
|
||||
import localStorage from '../../../infrastructure/local-storage'
|
||||
|
||||
function GoToCodeButton({
|
||||
position,
|
||||
|
@ -80,7 +81,7 @@ function GoToPdfButton({
|
|||
bsStyle="default"
|
||||
bsSize="xs"
|
||||
onClick={() => syncToPdf(cursorPosition)}
|
||||
disabled={syncToPdfInFlight}
|
||||
disabled={syncToPdfInFlight || !cursorPosition}
|
||||
className={buttonClasses}
|
||||
aria-label={t('go_to_code_location_in_pdf')}
|
||||
>
|
||||
|
@ -110,7 +111,12 @@ function PdfSynctexControls() {
|
|||
setHighlights,
|
||||
} = useCompileContext()
|
||||
|
||||
const [cursorPosition, setCursorPosition] = useState(null)
|
||||
const [cursorPosition, setCursorPosition] = useState(() => {
|
||||
const position = localStorage.getItem(
|
||||
`doc.position.${ide.editorManager.getCurrentDocId()}`
|
||||
)
|
||||
return position ? position.cursorPosition : null
|
||||
})
|
||||
|
||||
const isMounted = useIsMounted()
|
||||
|
||||
|
|
Loading…
Reference in a new issue