pull/118/head
Jon Eugster 2 years ago
parent 9a75102121
commit b780c7601f

@ -90,7 +90,8 @@ export function CommandLine({proofPanelRef}: {proofPanelRef: React.MutableRefObj
/** Load all goals an messages of the current proof (line-by-line) and save /** Load all goals an messages of the current proof (line-by-line) and save
* the retrieved information into context (`ProofContext`) * the retrieved information into context (`ProofContext`)
*/ */
const loadAllGoals = React.useCallback((proofPanelRef) => { const loadAllGoals = React.useCallback(() => {
let goalCalls = [] let goalCalls = []
let msgCalls = [] let msgCalls = []
@ -182,7 +183,7 @@ export function CommandLine({proofPanelRef}: {proofPanelRef: React.MutableRefObj
proofPanelRef.current?.lastElementChild?.scrollIntoView() proofPanelRef.current?.lastElementChild?.scrollIntoView()
}) })
}) })
}, [commandLineInput, editor]) }, [commandLineInput, editor, rpcSess, uri, model, proofPanelRef])
// Run the command // Run the command
const runCommand = React.useCallback(() => { const runCommand = React.useCallback(() => {
@ -215,18 +216,21 @@ export function CommandLine({proofPanelRef}: {proofPanelRef: React.MutableRefObj
// React when answer from the server comes back // React when answer from the server comes back
useServerNotificationEffect('textDocument/publishDiagnostics', (params: PublishDiagnosticsParams) => { useServerNotificationEffect('textDocument/publishDiagnostics', (params: PublishDiagnosticsParams) => {
if (params.uri == editor.getModel().uri.toString()) { if (params.uri == uri) {
setProcessing(false) setProcessing(false)
loadAllGoals(proofPanelRef) loadAllGoals()
if (!hasErrors(params.diagnostics)) { if (!hasErrors(params.diagnostics)) {
setCommandLineInput("") setCommandLineInput("")
editor.setPosition(editor.getModel().getFullModelRange().getEndPosition()) editor.setPosition(editor.getModel().getFullModelRange().getEndPosition())
} }
} else {
// console.debug(`expected uri: ${uri}, got: ${params.uri}`)
// console.debug(params)
} }
// TODO: This is the wrong place apparently. Where do wee need to load them? // TODO: This is the wrong place apparently. Where do wee need to load them?
// TODO: instead of loading all goals every time, we could only load the last one // TODO: instead of loading all goals every time, we could only load the last one
// loadAllGoals() // loadAllGoals()
}, []); }, [uri]);
useEffect(() => { useEffect(() => {
const myEditor = monaco.editor.create(inputRef.current!, { const myEditor = monaco.editor.create(inputRef.current!, {
@ -293,11 +297,13 @@ export function CommandLine({proofPanelRef}: {proofPanelRef: React.MutableRefObj
return () => { l.dispose() } return () => { l.dispose() }
}, [oneLineEditor, runCommand]) }, [oneLineEditor, runCommand])
// BUG: Causes `file closed` error
//TODO: Intention is to run once when loading, does that work? //TODO: Intention is to run once when loading, does that work?
useEffect(() => { useEffect(() => {
console.debug('time to update') console.debug(`time to update: ${uri} \n ${rpcSess}`)
loadAllGoals(proofPanelRef) console.debug(rpcSess)
}, []) loadAllGoals()
}, [rpcSess])
/** Process the entered command */ /** Process the entered command */
const handleSubmit : React.FormEventHandler<HTMLFormElement> = (ev) => { const handleSubmit : React.FormEventHandler<HTMLFormElement> = (ev) => {

Loading…
Cancel
Save