Skip to content
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

Overwrite editor options for vscode.open and vscode.diff #110398

Closed
wants to merge 2 commits into from

Conversation

bpasero
Copy link
Member

@bpasero bpasero commented Nov 11, 2020

This PR fixes #85636

@bpasero
Copy link
Member Author

bpasero commented Nov 11, 2020

PR up for discussion. I think less controversial is https://github.com/microsoft/vscode/pull/110398/files#diff-9bc927a30b92207292bb17a10e58c2ffe05cc22d5ea5ddcd7595cb19dbe50696 where all the logic of rewriting editor options is handled within the API command so that we can reuse this in other places like SCM and timeline.

@jrieken need some advice if this direction is OK for the second part. My head spins a bit because I am changing code that I do not have full knowledge of, namely:

// this enables `vscode.open` and `vscode.diff` to benefit
// from the actual editor options to use based on the context
// (e.g. invocation from a custom tree view)
result.arguments = command.arguments;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried the same thing right now and I can report that it doesn't work... This is what now happens

  • the arguments go through normal JSON-serialization (which for vscode.Range is special)
  • the command get send to the renderer
  • the renderer has vscode.open registered as well (need @alexdima to refresh my memory here)
  • when selecting an item in the tree the renderer-side vscode.open command is invoked and it fails to convert the selection/range argument

Copy link
Member

@jrieken jrieken Nov 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems have not coordinated well - sorry for the duplication. I have pushed some work here: https://github.com/microsoft/vscode/compare/joh/open

The idea is that CommandConverter#toInternal doesn't only create/feed the delegate command but that it actually converts some (API) commands to the internal variant. E.g a tree item will then be using _workbench.open and so on

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jrieken What can I help with?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is src/vs/workbench/api/common/apiCommands.ts which registers API commands on both sides - renderer and extension host. Not sure why that was done. Also, it registers commands that accept arguments which are types of vsocde.d.ts which means they "don't survive" the JSON serialisation/deserialisation, like vscode.Selection.

Copy link
Member

@jrieken jrieken Nov 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember... We made API command registration extension host only so that we can have multiple extension host (the global flag) but then we hit bugs with API-commands that escaped the extension host without treatment, like in markdown and then we added some API-commands to the renderer as well. It seems that some have evolved into a state where they only partially work in the renderer

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jrieken I think your changes in https://github.com/microsoft/vscode/compare/joh/open are cleaner, so I am fine to drop my work and only keep the special massaging of the 2 commands on the main side. To clarify, this would mean we end up having _workbench.open as command in the tree and not vscode.open? I actually prefer that because now I need to depend on some internal API knowledge in the tree. I would rather depend on _workbench.open 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it will be _workbench.open and it's friends. I have created #110455 which I am planning to merge despite some polish of where to revive uris and so

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#110455 is merged

@bpasero
Copy link
Member Author

bpasero commented Nov 12, 2020

Ok, actual solution is now in #110475

@bpasero bpasero closed this Nov 12, 2020
@bpasero bpasero deleted the ben/85636 branch November 12, 2020 13:18
@github-actions github-actions bot locked and limited conversation to collaborators Dec 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TreeDataProvider: allow single click and double click to work the same way they do in the file exporer
3 participants