Conversation
| } | ||
| } | ||
|
|
||
| onNewTacticState(handler_name: string, handler: (state: string, widget: object) => void): void { |
There was a problem hiding this comment.
| onNewTacticState(handler_name: string, handler: (state: string, widget: object) => void): void { | |
| onNewTacticState(handler_name: string, handler: (loc: Location, state: InfoResponse) => void): void { |
The widget field doesn't really contain any information (it's an id that you pass to the get_widget command). You probably also want the location (filename & position) so that you can insert something there.
Can you explain what the handler_name should be? Is this the name of the other extension?
I'm not sure if it's possible, but the nicest way would be to use the EventEmitter class from vscode:
private onNewTacticStateEmitter = new EventEmitter<{ location: Location, info: InfoResponse }>();
onNewTacticState = this.onNewTacticStateEmitter.event;| context.subscriptions.push(languages.registerDocumentLinkProvider(LEAN_MODE, | ||
| new LibraryNoteLinkProvider())); | ||
|
|
||
| return {'infoView': infoView}; // export infoView for other plugins to use |
There was a problem hiding this comment.
| return {'infoView': infoView}; // export infoView for other plugins to use | |
| return {onNewTacticState: infoView.onNewTacticState}; // export infoView for other plugins to use |
I'd rather export only the event.
| ), | ||
| this.proxyConnection.jsonMessage.on(e => | ||
| this.proxyConnection.jsonMessage.on(e => { | ||
| if ('record' in e && 'state' in e.record && 'widget' in e.record){ |
There was a problem hiding this comment.
This will trigger on every hover as well (i.e., when you move the mouse around). A better place to intercept would be here:
Line 173 in 2b43982
You'd then need to send a message from the webview back to the extension like this:
vscode-lean/infoview/server.ts
Lines 25 to 27 in 2b43982
And receive the message here:
Line 195 in 2b43982
Added the widget argument (containing line and column) to the callback