diff --git a/client/src/components/hints.tsx b/client/src/components/hints.tsx index 10fe55e..e488464 100644 --- a/client/src/components/hints.tsx +++ b/client/src/components/hints.tsx @@ -68,12 +68,12 @@ function hasHiddenHints(step: InteractiveGoalsWithHints): boolean { } -export function MoreHelpButton() { +export function MoreHelpButton({selected=null} : {selected?: number}) { const {proof, setProof} = React.useContext(ProofContext) const {deletedChat, setDeletedChat, showHelp, setShowHelp} = React.useContext(DeletedChatContext) - let k = proof.steps.length - (lastStepHasErrors(proof) ? 2 : 1) + let k = (selected === null) ? (proof.steps.length - (lastStepHasErrors(proof) ? 2 : 1)) : selected const activateHiddenHints = (ev) => { // If the last step (`k`) has errors, we want the hidden hints from the diff --git a/client/src/components/infoview/main.tsx b/client/src/components/infoview/main.tsx index 3e768fa..74c8df1 100644 --- a/client/src/components/infoview/main.tsx +++ b/client/src/components/infoview/main.tsx @@ -155,7 +155,20 @@ export function Main(props: { world: string, level: number, data: LevelInfo}) { const {worldId, levelId} = React.useContext(WorldLevelIdContext) const { proof, setProof } = React.useContext(ProofContext) + const {selectedStep, setSelectedStep} = React.useContext(SelectionContext) + const { setDeletedChat, showHelp, setShowHelp } = React.useContext(DeletedChatContext) + + function toggleSelection(line: number) { + return (ev) => { + console.debug('toggled selection') + if (selectedStep == line) { + setSelectedStep(undefined) + } else { + setSelectedStep(line) + } + } + } console.debug(`template: ${props.data?.template}`) // React.useEffect (() => { @@ -182,6 +195,19 @@ export function Main(props: { world: string, level: number, data: LevelInfo}) { const curUri = useEventResult(ec.events.changedCursorLocation, loc => loc?.uri); + const curPos: DocumentPosition | undefined = + useEventResult(ec.events.changedCursorLocation, loc => loc ? { uri: loc.uri, ...loc.range.start } : undefined) + + // Effect when the cursor changes in the editor + React.useEffect(() => { + // TODO: this is a bit of a hack and will yield unexpected behaviour if lines + // are indented. + let newPos = curPos?.line + (curPos?.character == 0 ? 0 : 1) + + // scroll the chat along + setSelectedStep(newPos) + }, [curPos]) + useClientNotificationEffect( 'textDocument/didClose', (params: DidCloseTextDocumentParams) => { @@ -208,6 +234,11 @@ export function Main(props: { world: string, level: number, data: LevelInfo}) { ret =