Preventing viewport reset on reload/refresh of diagram #1547
-
I'm creating a VSCode-integrated GLSP project, and I'm working on trying to prevent the GLSP client viewport from reseting it's position/zoom when the diagram is refreshed/reloaded. I have been trying to implement a draft solution suggested by @tortmayr in this discussion post, but it seems like I can't create an instance of the
The error seems to be completely out of nowhere, so I could use some assistance. reload-action-handler.ts
index.ts (in GLSP client files)
diagram-module.ts (GLSP client files)
As far as I'm aware, there shouldn't be anything preventing me from calling @tortmayr the post is a little old, so I was wondering if something about the action and its handler might need to be tweaked? Any help is much appreciated, thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
@tortmayr Just wanted to follow up in case you missed this! |
Beta Was this translation helpful? Give feedback.
-
Hi @david-pa , This works for other GLSP base actions because they are defined in the "@eclipse-glsp/protocol" package which is a common package that can be used in both browser and node environments. To fix the issue you have to make sure that you don"t import directly from "@eclipse-glsp/browser" in your vscode-extension. Only the webview part should depend on the client directly. |
Beta Was this translation helpful? Give feedback.
You are right, not everything is exported from protocol. Especially the
EditorContextService
however is not actually protocol material as it heavily relies on the selection and other client-level services.As far as I can tell, you need to avoid the
@eclipse-glsp/client
imports from the code where you callReloadModelAction.create
so the best option would be to ensure that the definition/creation of that action are not in the same file (or even package) as the handling of that action which requires the actual client imports. That is one of the reasons, we often split something into a protocol and have the handling somewhere else. Could you give that a try?