vscode-pull-request-github icon indicating copy to clipboard operation
vscode-pull-request-github copied to clipboard

Allow keyboard shortcut for Open File

Open jasonwilliams opened this issue 3 years ago • 4 comments

(I searched existing issues).

The workflow of of this extension is a bit broken when you want to make any edit for a file you're viewing in a PR. Or even if you just want to read the file without the green diff colour over it.

Clicking on the side bar you end up in a view like below: image

I want to switch to this view: image

I want to make edits to this file or see it in action, how can I switch to opening it normally? I can't find any option of doing this. Right clicking on the tree view only offers me "open in Github". It would be really nice if there's a keybinding to this, similar to Gitlens for VSCode which allows you to toggle from diff view to opening the file.

Gitlens offers this (as well as Git too) image

Similar issue: https://github.com/microsoft/vscode-pull-request-github/issues/868 (although this is more editing, which I think is possible)

jasonwilliams avatar Jun 14 '22 21:06 jasonwilliams

Can some keybindings or a toggle be offered? When I try setting up these binding manually I get:

image

When in diff view you don't have the command to open the file (I think this is related to the above), which could be a bug image

jasonwilliams avatar Jun 14 '22 21:06 jasonwilliams

There is an inline action (icon) in the tree for this: image

It's also in the top right editor actions when you have a diff open.

@lszomoru the git.openFile command is used in the editor menu when in the diff editor, even when it's a PR diff (https://github.com/microsoft/vscode/blob/6e1ea79174dd791a0db49c96a9b986ae44823306/extensions/git/package.json#L1468-L1472). It looks like that command expects a uri. Would you accept a PR for it to use the active editor for the uri so that users can configure a keyboard shortcut for it?

alexr00 avatar Jun 16 '22 15:06 alexr00

@alexr00, apologies for not getting back to you on this. I just looked at the code, and if the git.openFile command is invoked without a URI, the command will fallback to the URI of the active editor document (assuming that it exists). From the looks of it everything is already in place to set up a keyboard shortcut unless I am missing something.

lszomoru avatar Jul 28 '22 15:07 lszomoru

I raised an issue with VSCode because I think there's a deeper underlying issue here where diff views don't always operate the same way. In other words it would be good for VSCode itself to provide some hook for extensions (such as this one) to plug into when trying to open either split from a diff view.

If you're a user of Git, Gitlens and Pull requests And Issues for example (like a lot of people would be), it can be confusing knowing when command/action to fire to view a diff side. Please have a look and let me know whet you think

jasonwilliams avatar Jul 28 '22 16:07 jasonwilliams

I would love for this to be standardized within VSCode itself because there are extensions and features that have a slightly different handling of diff views. I would be nice if there was a single unified way of opening a file from one of the diff splits. Sadly my issue didn't get enough votes to be looked at.

jasonwilliams avatar Oct 31 '22 14:10 jasonwilliams

@jasonwilliams for this specific issue you can now use a keyboard shortcut to open the modified file starting with today's pre-release build (change was commit https://github.com/microsoft/vscode-pull-request-github/commit/262c85738f4f752fd0f545fe17585a971c0ff708). The command is pr.openModifiedFile.

alexr00 avatar Dec 09 '22 12:12 alexr00

Thanks @alexr00 that's appreciated. However I have been working on the core VSCode to fix this because you can get this view in many different ways. There should be a standard UX for diff views across the board.

Attaching this command at extension level is too jarring because "git", "gitlens", "timeline", "compare selected" and other places open up the same UI, so as a user you need to learn a growing number of commands. It's also inconsistent because sometimes those commands work and sometimes there isn't a command at all (depending on how you got there).

Not sure if @bpasero has any opinion on this.

jasonwilliams avatar Dec 09 '22 14:12 jasonwilliams

https://github.com/microsoft/vscode/pull/165765 is now merged

jasonwilliams avatar Dec 12 '22 14:12 jasonwilliams