show global errors when no goals present.
This commit is contained in:
@@ -16,6 +16,14 @@ function Infoview({ editor, editorApi, leanClient } : {editor: monaco.editor.ISt
|
|||||||
const [goals, setGoals] = useState<any[]>(null)
|
const [goals, setGoals] = useState<any[]>(null)
|
||||||
const [completed, setCompleted] = useState<boolean>(false)
|
const [completed, setCompleted] = useState<boolean>(false)
|
||||||
const [diagnostics, setDiagnostics] = useState<any[]>(undefined)
|
const [diagnostics, setDiagnostics] = useState<any[]>(undefined)
|
||||||
|
|
||||||
|
/* `globalDiagnostics` is a work-around to show something when the proof is complete
|
||||||
|
but had previous subgoals with `sorry` or errors.
|
||||||
|
|
||||||
|
It is displayed whenever there are no goals and no (error)-messages present and the proof
|
||||||
|
isn't complete. */
|
||||||
|
const [globalDiagnostics, setGlobalDiagnostics] = useState<any[]>(undefined)
|
||||||
|
|
||||||
const [uri, setUri] = useState<string>()
|
const [uri, setUri] = useState<string>()
|
||||||
console.log(rpcSession)
|
console.log(rpcSession)
|
||||||
const fetchInteractiveGoals = () => {
|
const fetchInteractiveGoals = () => {
|
||||||
@@ -40,6 +48,10 @@ function Infoview({ editor, editorApi, leanClient } : {editor: monaco.editor.ISt
|
|||||||
"textDocument":{uri},
|
"textDocument":{uri},
|
||||||
"position": pos
|
"position": pos
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
|
|
||||||
|
/* Workaround to not display the error `unsolved goals` */
|
||||||
|
if (res) {res = res.filter(x => x.message.trim() !== 'unsolved goals')}
|
||||||
|
|
||||||
setDiagnostics(res ? res : undefined)
|
setDiagnostics(res ? res : undefined)
|
||||||
console.log(res)
|
console.log(res)
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
@@ -60,6 +72,7 @@ function Infoview({ editor, editorApi, leanClient } : {editor: monaco.editor.ISt
|
|||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
// Check that there are no errors and no warnings
|
// Check that there are no errors and no warnings
|
||||||
setCompleted(!res.some(({severity}) => severity <= 2))
|
setCompleted(!res.some(({severity}) => severity <= 2))
|
||||||
|
setGlobalDiagnostics(res)
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
})
|
})
|
||||||
@@ -100,7 +113,8 @@ function Infoview({ editor, editorApi, leanClient } : {editor: monaco.editor.ISt
|
|||||||
}, [editor, leanClient, rpcSession])
|
}, [editor, leanClient, rpcSession])
|
||||||
|
|
||||||
return (<div>
|
return (<div>
|
||||||
<TacticState goals={goals} diagnostics={diagnostics} completed={completed}></TacticState>
|
<TacticState goals={goals} diagnostics={diagnostics} completed={completed}
|
||||||
|
globalDiagnostics={globalDiagnostics}></TacticState>
|
||||||
</div>)
|
</div>)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,10 +96,16 @@ function OtherGoal({ goal }) {
|
|||||||
</Accordion>)
|
</Accordion>)
|
||||||
}
|
}
|
||||||
|
|
||||||
function TacticState({ goals, diagnostics, completed }) {
|
function TacticState({ goals, diagnostics, completed, globalDiagnostics }) {
|
||||||
const hasError = typeof diagnostics === "object" && diagnostics.length > 0
|
|
||||||
const hasGoal = goals !== null && goals.length > 0
|
const hasGoal = goals !== null && goals.length > 0
|
||||||
const hasManyGoal = hasGoal && goals.length > 1
|
const hasManyGoal = hasGoal && goals.length > 1
|
||||||
|
|
||||||
|
if (!(hasGoal || completed) && globalDiagnostics) {
|
||||||
|
diagnostics = [{"severity" : 4, "message": "Showing global messages:"}, ...globalDiagnostics]
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasError = typeof diagnostics === "object" && diagnostics.length > 0
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ height: "100%" }}>
|
<Box sx={{ height: "100%" }}>
|
||||||
{completed && <Typography variant="h6">Level completed ! 🎉</Typography>}
|
{completed && <Typography variant="h6">Level completed ! 🎉</Typography>}
|
||||||
|
|||||||
Reference in New Issue
Block a user