Skip to content

Commit

Permalink
Improve input and deletion of typewriter #122
Browse files Browse the repository at this point in the history
  • Loading branch information
joneugster committed Oct 21, 2023
1 parent b6bc778 commit 84ad619
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 4 additions & 2 deletions client/src/components/infoview/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ function Command({ command, deleteProof }: { command: string, deleteProof: any }
if (!command) { return <></> }
return <div className="command">
<div className="command-text">{command}</div>
<Button to="" className="undo-button btn btn-inverted" title="Delete this and future commands" onClick={deleteProof}>
<FontAwesomeIcon icon={faDeleteLeft} />&nbsp;Delete
<Button to="" className="undo-button btn btn-inverted" title="Retry proof from here" onClick={deleteProof}>
<FontAwesomeIcon icon={faDeleteLeft} />&nbsp;Retry
</Button>
</div>
}
Expand Down Expand Up @@ -319,6 +319,7 @@ export function TypewriterInterface(props: { world: string, level: number, data:
const uri = model.uri.toString()
const gameId = React.useContext(GameIdContext)
const { proof } = React.useContext(ProofContext)
const { setTypewriterInput } = React.useContext(InputModeContext)
const { selectedStep, setSelectedStep } = React.useContext(SelectionContext)
const { setDeletedChat, showHelp, setShowHelp } = React.useContext(DeletedChatContext)

Expand Down Expand Up @@ -349,6 +350,7 @@ export function TypewriterInterface(props: { world: string, level: number, data:
forceMoveMarkers: false
}])
setSelectedStep(undefined)
setTypewriterInput(proof[line].command)
ev.stopPropagation()
}
}
Expand Down
9 changes: 8 additions & 1 deletion client/src/components/infoview/typewriter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export function Typewriter({hidden, disabled}: {hidden?: boolean, disabled?: boo
text: typewriterInput.trim() + "\n",
forceMoveMarkers: false
}])
setTypewriterInput('')
}

editor.setPosition(pos)
Expand All @@ -211,13 +212,19 @@ export function Typewriter({hidden, disabled}: {hidden?: boolean, disabled?: boo
}
}, [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
useServerNotificationEffect('textDocument/publishDiagnostics', (params: PublishDiagnosticsParams) => {
if (params.uri == uri) {
setProcessing(false)
loadAllGoals()
if (!hasErrors(params.diagnostics)) {
setTypewriterInput("")
//setTypewriterInput("")
editor.setPosition(editor.getModel().getFullModelRange().getEndPosition())
}
} else {
Expand Down

0 comments on commit 84ad619

Please sign in to comment.