Skip to content

Commit

Permalink
Ensure correct dispatching of server-target actions from the extensio…
Browse files Browse the repository at this point in the history
…n host
  • Loading branch information
tortmayr committed Feb 18, 2024
1 parent a269aa7 commit 9c77a95
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions packages/vscode-integration/src/common/glsp-vscode-connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,20 @@ export class GlspVscodeConnector<D extends vscode.CustomDocument = vscode.Custom
*/
protected sendActionToClient(clientId: string, action: Action): void {
this.sendMessageToClient(clientId, {
clientId: clientId,
action: action,
__localDispatch: true
clientId,
action
});
}

/**
* Send an action to the server for the given client (id).
* @param clientId Id of the client.
* @param action Action to send
*/
protected sendActionToServer(clientId: string, action: Action): void {
this.options.server.onSendToServerEmitter.fire({ clientId, action });
}

/**
* Provides the functionality of the VSCode integration.
*
Expand Down Expand Up @@ -431,10 +439,10 @@ export class GlspVscodeConnector<D extends vscode.CustomDocument = vscode.Custom
this.onDidChangeCustomDocumentEventEmitter.fire({
document: client.document,
undo: () => {
this.sendActionToClient(client.clientId, UndoAction.create());
this.sendActionToServer(client.clientId, UndoAction.create());
},
redo: () => {
this.sendActionToClient(client.clientId, RedoAction.create());
this.sendActionToServer(client.clientId, RedoAction.create());
}
});
} else if (message.action.isDirty) {
Expand Down Expand Up @@ -563,7 +571,7 @@ export class GlspVscodeConnector<D extends vscode.CustomDocument = vscode.Custom
resolve();
}
});
this.sendActionToClient(clientId, SaveModelAction.create({ fileUri: destination?.path }));
this.sendActionToServer(clientId, SaveModelAction.create({ fileUri: destination?.path }));
});
} else {
if (this.options.logging) {
Expand All @@ -586,7 +594,7 @@ export class GlspVscodeConnector<D extends vscode.CustomDocument = vscode.Custom
if (clientId) {
const client = this.clientMap.get(clientId);
if (client?.webviewEndpoint.webviewPanel.active) {
this.sendActionToClient(
this.sendActionToServer(
clientId,
RequestModelAction.create({
options: {
Expand Down

0 comments on commit 9c77a95

Please sign in to comment.