Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: optional user widget names #376

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lean4-infoview-api/src/rpcApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ export function getGoToLocation(rs: RpcSessionAtPos, kind: GoToKind, info: InfoW

export interface UserWidget {
id: string;
/** Pretty user name. */
name: string;
/** Newer widget APIs do not send this.
* In previous versions, it used to be a user-readable name to show in a title bar. */
name?: string;
/** A hash (provided by Lean) of the widgetSource's sourcetext.
* This is used to look up the WidgetSource object.
*/
Expand Down
23 changes: 16 additions & 7 deletions lean4-infoview/src/infoview/info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,22 @@ const InfoDisplayContent = React.memo((props: InfoDisplayContentProps) => {
initiallyOpen={config.showExpectedType}
displayCount={false}
togglingAction='toggleExpectedType' />
{userWidgets.map(widget =>
<details key={`widget::${widget.id}::${widget.range?.toString()}`} open>
<summary className='mv2 pointer'>{widget.name}</summary>
<PanelWidgetDisplay pos={pos} goals={goals ? goals.goals : []} termGoal={termGoal}
selectedLocations={selectedLocs} widget={widget}/>
</details>
)}
{userWidgets.map(widget => {
const inner =
<PanelWidgetDisplay key={`widget::${widget.id}::${widget.range?.toString()}`}
pos={pos}
goals={goals ? goals.goals : []}
termGoal={termGoal}
selectedLocations={selectedLocs}
widget={widget} />
if (widget.name)
return <details key={`widget::${widget.id}::${widget.range?.toString()}`} open>
<summary className='mv2 pointer'>{widget.name}</summary>
{inner}
</details>
else
return inner
})}
<div style={{display: hasMessages ? 'block' : 'none'}} key='messages'>
<details key='messages' open>
<summary className='mv2 pointer'>Messages ({messages.length})</summary>
Expand Down
Loading