-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
handle cycles in json.stringify #5196
Conversation
Could we use a library (i.e. https://www.npmjs.com/package/json-cycle) instead of copying code? |
It has exactly the same code, copied... same license inside the cycle.js file. In addition, since in Theia's code we first stringify and then concat the results to a larger json, I had to extend a bit to support a baseJsonPath. for example:
also, after finishing this I realized that the issue is important in Theia due to how the tree-view is implemented, while in vscode they do not do this, because they avoided the problem from the first place (at least for tree-view) - see my last comment #5121 |
The way the tree view was implemented (TreeViewsExt, TreeViewItem, tree-view-main.tsx etc) is that the server-side object representing a TreeItem is moved (via json-rpc) from server to client upon getChildren call (specifically the original object is placed under metadata defined in TreeViewItem. This back and forth move of the actual object of the tree-item is the source of some major problems: these objects tend to have circular-references, thus pose a challenge to serialize them (fixed in my PR) Last commit changes it to work like vs-code. and not move the tree-items' customer objects of the plugin/vs-code extension back and forth at all. |
@ariel-bentu we could get rid of JSONRetrocycle/JSONDecycle as well ? |
I suppose we can remove the decycling then - I will add this in an hour |
I confirm that it fixes #5121. |
@benoitf since I'm not familiar with the testing infra, and I assume this breaks tests because it is really changing how things work, so the tests needs to be fixed - can you help with that? |
@ariel-bentu I've opened a PR that fixes tests |
c7689ea
to
f78a72b
Compare
Anything else I should do to make this PR get merged? |
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.
looks like a proper solution, please use rebase to integrate changes, we try to keep git history linear and avoid merge commits
@marcdumais-work do we need a CQ for the code which is copied? |
No. Eventually I did not copy the code, as we don't need the decycle code. the fix changes the way we handle tree initiated commands. |
@vince-fugnitto there is no copied code |
@ariel-bentu it seems rebase didn't worked well |
Thanks, I'll wait for the cleanup. |
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.
See https://github.com/theia-ide/theia/pull/5196/files#r287686664
Please squash the history. Change is really small for 7 commits.
all squashed to 1 commit |
@akosyakov, in command-registry.ts, you can see that when command is executed, it prefers the selected item over the args passed. So, when inline action is triggered, it is not effective to pass the current node id, but instead, I need to set the current item to be the selected item. Thanks See code:
|
Signed-off-by: Ariel Bentolila <ariel.bentolila@sap.com>
@akosyakov, I modified it to select the node, otherwise inline actions don't work properly. I assume they don't work also now (prior to this PR), if another item is selected and you hover one non-selected item and click the inline action. the context would be the selected item and not the one you clicked on. So I added to the onClick of the inline icon this:
|
@akosyakov - can you merge this please before the new version? thanks |
the minimal fix is here: #5310 |
fixes #5121 - circular references in JSON in RPC traffic
It uses modified code (converted to typescript) from https://raw.githubusercontent.com/douglascrockford/JSON-js/master/cycle.js - according to header in this file - this is the license:
It detects circular references while stringify-ing JSON, and converts to to a text reference. later after parse, it can restore the right reference.
This was important to support https://github.com/mtxr/vscode-sqltools run in Theia.