-
Notifications
You must be signed in to change notification settings - Fork 49
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
Get position #281
base: master
Are you sure you want to change the base?
Get position #281
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -28,8 +28,10 @@ export class InfoProvider implements Disposable { | |||||||||||
|
||||||||||||
private hoverDecorationType: TextEditorDecorationType; | ||||||||||||
|
||||||||||||
constructor(private server: Server, private leanDocs: DocumentSelector, private context: ExtensionContext, private staticServer?: StaticServer) { | ||||||||||||
// Callbacks when a new tactic state is received | ||||||||||||
private tacticStateHandlers: { [id: string] : (state: string, widget: object) => void; } = {}; | ||||||||||||
|
||||||||||||
constructor(private server: Server, private leanDocs: DocumentSelector, private context: ExtensionContext, private staticServer?: StaticServer) { | ||||||||||||
this.statusBarItem = window.createStatusBarItem(StatusBarAlignment.Right, 1000); | ||||||||||||
|
||||||||||||
this.hoverDecorationType = window.createTextEditorDecorationType({ | ||||||||||||
|
@@ -108,6 +110,10 @@ export class InfoProvider implements Disposable { | |||||||||||
} | ||||||||||||
} | ||||||||||||
|
||||||||||||
onNewTacticState(handler_name: string, handler: (state: string, widget: object) => void): void { | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
The Can you explain what the I'm not sure if it's possible, but the nicest way would be to use the private onNewTacticStateEmitter = new EventEmitter<{ location: Location, info: InfoResponse }>();
onNewTacticState = this.onNewTacticStateEmitter.event; |
||||||||||||
this.tacticStateHandlers[handler_name] = handler; | ||||||||||||
} | ||||||||||||
|
||||||||||||
private makeProxyConnection() { | ||||||||||||
if (this.proxyConnection) { | ||||||||||||
this.proxyConnection.dispose(); | ||||||||||||
|
@@ -120,12 +126,17 @@ export class InfoProvider implements Disposable { | |||||||||||
payload: JSON.stringify(e) | ||||||||||||
}) | ||||||||||||
), | ||||||||||||
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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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
|
||||||||||||
for (const [handlerName, handler] of Object.entries(this.tacticStateHandlers)) { | ||||||||||||
handler(e.record.state, e.record.widget); | ||||||||||||
} | ||||||||||||
} | ||||||||||||
this.postMessage({ | ||||||||||||
command: 'server_event', | ||||||||||||
payload: JSON.stringify(e) | ||||||||||||
}) | ||||||||||||
) | ||||||||||||
}); | ||||||||||||
}) | ||||||||||||
); | ||||||||||||
|
||||||||||||
} | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather export only the event.