Skip to content

Commit

Permalink
added spinner option
Browse files Browse the repository at this point in the history
  • Loading branch information
YnirPaz committed Dec 22, 2024
1 parent c5293e4 commit d37a89b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
2 changes: 2 additions & 0 deletions lean4-infoview-api/src/infoviewApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export interface InfoviewConfig {
emphasizeFirstGoal: boolean
reverseTacticState: boolean
showTooltipOnHover: boolean
disableLoadingSpinner: boolean
}

export const defaultInfoviewConfig: InfoviewConfig = {
Expand All @@ -97,6 +98,7 @@ export const defaultInfoviewConfig: InfoviewConfig = {
emphasizeFirstGoal: false,
reverseTacticState: false,
showTooltipOnHover: true,
disableLoadingSpinner: false,
}

export type InfoviewActionKind =
Expand Down
24 changes: 14 additions & 10 deletions lean4-infoview/src/infoview/info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ interface InfoStatusBarProps extends InfoPinnable, PausableProps {
}

const InfoStatusBar = React.memo((props: InfoStatusBarProps) => {
const config = React.useContext(ConfigContext)
const { kind, onPin, status, pos, isPaused, setPaused, triggerUpdate } = props

const ec = React.useContext(EditorContext)
Expand Down Expand Up @@ -80,16 +81,19 @@ const InfoStatusBar = React.memo((props: InfoStatusBarProps) => {
{isPinned && !isPaused && ' (pinned)'}
{!isPinned && isPaused && ' (paused)'}
{isPinned && isPaused && ' (pinned and paused)'}
<span style={spinnerStyle} className="mh2 codicon codicon-loading" title="updating">
<style>
{`
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
`}
</style>
</span>
{!config.disableLoadingSpinner && (
<span style={spinnerStyle} className="mh2 codicon codicon-loading" title="updating">
<style>
{`
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
`}
</style>
</span>
)}

<span
className="fr"
onClick={e => {
Expand Down
5 changes: 5 additions & 0 deletions vscode-lean4/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@
"default": true,
"markdownDescription": "Show the tooltip for an interactive element (e.g. a subexpression) when the pointer hovers over that element. When disabled, the element must be clicked for the tooltip to show up."
},
"lean4.infoview.disableLoadingSpinner": {
"type": "boolean",
"default": false,
"markdownDescription": "Disable the loading spinner on the infoview."
},
"lean4.elaborationDelay": {
"type": "number",
"default": 200,
Expand Down
4 changes: 4 additions & 0 deletions vscode-lean4/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ export function getInfoViewShowTooltipOnHover(): boolean {
return workspace.getConfiguration('lean4.infoview').get('showTooltipOnHover', true)
}

export function getInfoViewDisableLoadingSpinner(): boolean {
return workspace.getConfiguration('lean4.infoview').get('disableLoadingSpinner', false)
}

export function getElaborationDelay(): number {
return workspace.getConfiguration('lean4').get('elaborationDelay', 200)
}
Expand Down
2 changes: 2 additions & 0 deletions vscode-lean4/src/infoview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
getInfoViewAutoOpen,
getInfoViewAutoOpenShowsGoal,
getInfoViewDebounceTime,
getInfoViewDisableLoadingSpinner,
getInfoViewEmphasizeFirstGoal,
getInfoViewReverseTacticState,
getInfoViewShowExpectedType,
Expand Down Expand Up @@ -664,6 +665,7 @@ export class InfoProvider implements Disposable {
emphasizeFirstGoal: getInfoViewEmphasizeFirstGoal(),
reverseTacticState: getInfoViewReverseTacticState(),
showTooltipOnHover: getInfoViewShowTooltipOnHover(),
disableLoadingSpinner: getInfoViewDisableLoadingSpinner(),
})
}

Expand Down

0 comments on commit d37a89b

Please sign in to comment.