Improve input and deletion of typewriter #122

world_overviews
joneugster 1 year ago
parent b6bc77828d
commit 84ad619537

@ -233,8 +233,8 @@ function Command({ command, deleteProof }: { command: string, deleteProof: any }
if (!command) { return <></> } if (!command) { return <></> }
return <div className="command"> return <div className="command">
<div className="command-text">{command}</div> <div className="command-text">{command}</div>
<Button to="" className="undo-button btn btn-inverted" title="Delete this and future commands" onClick={deleteProof}> <Button to="" className="undo-button btn btn-inverted" title="Retry proof from here" onClick={deleteProof}>
<FontAwesomeIcon icon={faDeleteLeft} />&nbsp;Delete <FontAwesomeIcon icon={faDeleteLeft} />&nbsp;Retry
</Button> </Button>
</div> </div>
} }
@ -319,6 +319,7 @@ export function TypewriterInterface(props: { world: string, level: number, data:
const uri = model.uri.toString() const uri = model.uri.toString()
const gameId = React.useContext(GameIdContext) const gameId = React.useContext(GameIdContext)
const { proof } = React.useContext(ProofContext) const { proof } = React.useContext(ProofContext)
const { setTypewriterInput } = React.useContext(InputModeContext)
const { selectedStep, setSelectedStep } = React.useContext(SelectionContext) const { selectedStep, setSelectedStep } = React.useContext(SelectionContext)
const { setDeletedChat, showHelp, setShowHelp } = React.useContext(DeletedChatContext) const { setDeletedChat, showHelp, setShowHelp } = React.useContext(DeletedChatContext)
@ -349,6 +350,7 @@ export function TypewriterInterface(props: { world: string, level: number, data:
forceMoveMarkers: false forceMoveMarkers: false
}]) }])
setSelectedStep(undefined) setSelectedStep(undefined)
setTypewriterInput(proof[line].command)
ev.stopPropagation() ev.stopPropagation()
} }
} }

@ -200,6 +200,7 @@ export function Typewriter({hidden, disabled}: {hidden?: boolean, disabled?: boo
text: typewriterInput.trim() + "\n", text: typewriterInput.trim() + "\n",
forceMoveMarkers: false forceMoveMarkers: false
}]) }])
setTypewriterInput('')
} }
editor.setPosition(pos) editor.setPosition(pos)
@ -211,13 +212,19 @@ export function Typewriter({hidden, disabled}: {hidden?: boolean, disabled?: boo
} }
}, [typewriterInput]) }, [typewriterInput])
useEffect(() => {
if (proof.length && hasInteractiveErrors(proof[proof.length - 1].errors)) {
setTypewriterInput(proof[proof.length - 1].command)
}
}, [proof])
// 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 == uri) { if (params.uri == uri) {
setProcessing(false) setProcessing(false)
loadAllGoals() loadAllGoals()
if (!hasErrors(params.diagnostics)) { if (!hasErrors(params.diagnostics)) {
setTypewriterInput("") //setTypewriterInput("")
editor.setPosition(editor.getModel().getFullModelRange().getEndPosition()) editor.setPosition(editor.getModel().getFullModelRange().getEndPosition())
} }
} else { } else {

Loading…
Cancel
Save