Skip to content

Commit

Permalink
Merge pull request #86 from eclipse-sprotty/dh/dispose-msg-handlers
Browse files Browse the repository at this point in the history
Dispose message handlers on webview dispose
  • Loading branch information
dhuebner authored Nov 17, 2023
2 parents e2c0d72 + 178af6e commit 5af86d4
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 30 deletions.
2 changes: 1 addition & 1 deletion packages/sprotty-vscode-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"dependencies": {
"sprotty-protocol": "~0.13.0",
"vscode-languageserver-protocol": "^3.17.2",
"vscode-messenger-common": "^0.4.3"
"vscode-messenger-common": "^0.4.5"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.30.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/sprotty-vscode-webview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"dependencies": {
"sprotty": "~0.13.0",
"sprotty-vscode-protocol": "^0.5.0",
"vscode-messenger-webview": "^0.4.3",
"vscode-messenger-webview": "^0.4.5",
"vscode-uri": "^3.0.6"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/sprotty-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"path": "^0.12.7",
"sprotty-vscode-protocol": "^0.5.0",
"vscode-languageclient": "^8.0.2",
"vscode-messenger": "^0.4.4"
"vscode-messenger": "^0.4.5"
},
"devDependencies": {
"@types/node": "^12.12.6",
Expand Down
40 changes: 22 additions & 18 deletions packages/sprotty-vscode/src/lsp/lsp-webview-endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,29 @@ export class LspWebviewEndpoint extends WebviewEndpoint {

protected override connect(): void {
super.connect();
this.messenger.onRequest(LspRequest,
async request => {
const result: any = request.params === undefined
? await this.languageClient.sendRequest(request.method)
: await this.languageClient.sendRequest(request.method, request.params);
const response: ResponseMessage = {
jsonrpc: '2.0',
id: request.id,
result
};
return response;
},
{ sender: this.messageParticipant }
this.disposables.push(
this.messenger.onRequest(LspRequest,
async request => {
const result: any = request.params === undefined
? await this.languageClient.sendRequest(request.method)
: await this.languageClient.sendRequest(request.method, request.params);
const response: ResponseMessage = {
jsonrpc: '2.0',
id: request.id,
result
};
return response;
},
{ sender: this.messageParticipant }
)
);
this.messenger.onNotification(LspNotification,
notification => {
this.languageClient.sendNotification(notification.method, notification.params);
},
{ sender: this.messageParticipant }
this.disposables.push(
this.messenger.onNotification(LspNotification,
notification => {
this.languageClient.sendNotification(notification.method, notification.params);
},
{ sender: this.messageParticipant }
)
);
}

Expand Down
22 changes: 13 additions & 9 deletions packages/sprotty-vscode/src/webview-endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,20 @@ export class WebviewEndpoint {
})
);
}
this.messenger.onNotification(ActionNotification,
message => this.receiveAction(message),
{ sender: this.messageParticipant }
this.disposables.push(
this.messenger.onNotification(ActionNotification,
message => this.receiveAction(message),
{ sender: this.messageParticipant }
)
);
this.messenger.onNotification(WebviewReadyNotification,
message => {
this.resolveWebviewReady();
this.sendDiagramIdentifier();
},
{ sender: this.messageParticipant }
this.disposables.push(
this.messenger.onNotification(WebviewReadyNotification,
message => {
this.resolveWebviewReady();
this.sendDiagramIdentifier();
},
{ sender: this.messageParticipant }
)
);
}

Expand Down

0 comments on commit 5af86d4

Please sign in to comment.