-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Feature] Enable navigation from diff view to editor #1407
Conversation
Simple proof of concept!
Previously only Right was enabled.
|
I think this feature would be very useful, but (as you mention yourself) I don't think hitting any key is the correct way to expose this:
I'm not sure what a better UI would be. I like the "edit button" in your mockup above, though that is only available when there are comments in the diff. Maybe simply a context menu entry? |
Currently uses VSStd2KCmdID.RETURN command.
This will fix navigation for the common case where a few lines have been added or removed from the working file. There is no fuzzy matching, it will simply pick the nearest matching line.
Hitting any key was just a way to get something working. In the latest revision I've changed it to use a VS command rather than a key. I'm currently using the
I agree that accidentally hitting a random key and ending up on a different view would be weird. Since there is already precedent for Enter to navigating to the editor, I don't think this would feel wrong. In fact, if the user did hit Enter hoping to edit the document, accidentally discovering this command would be a good thing. Since this command is only ever active on a read-only view, is there anywhere else it would make sense to navigate to?
Indeed and the majority of PR probably don't even have inline comments. This is definitely something we'd want to have easily accessible on all read-only PR files. A context menu entry would certainly make sense, but users wouldn't necessarily notice it on an already cluttered context menu. |
|
I took this out for a test drive! It looks like we don't checkout the PR branch when we switch from the diff view to the editor view. Can we change it so that we do? Otherwise, I'll end up editing the file in the wrong branch or be confused why some of the file's content has disappeared or is outdated.
I personally don't have a problem having the feature as a whole only available to comments in the diff. I interpreted this feature originally as a part of the inline review flow, specifically when I'm ready to address feedback. One thing that I noticed is that it would be nice is a way to quickly reference the feedback left after navigating to the editor view. Otherwise, I'll need to jump back and forth between the two views. This would be something that would need further speccing/designs and I don't think should hold up this pull request. However, I'm more than happy to continue the conversation in a separate issue. |
Added to `GitHub` submenu, but this isn't very discoverable.
We certainly don't want users inadvertently editing files on the wrong branch! In order of complexity, we could:
This feature certainly dovetails nicely with the inline review flow, but I've found myself using it as a standalone feature on PRs that don't have comments. The PR If for example there is a change part way into a large file on that is on the PR
Yes, definitely! I think this would be part of inline reviews in the editor. The current situation isn't actually too bad, because the user can hit |
|
I've now surfaced this command on the diff view context menu / It's pretty awkward to navigate to, not very discoverable and against the Visual Studio UI guidelines to have a single item on a sub-menu. 😉 I'll experiment to find a better location for it. I've labeled the command VS has a number of commands that navigate to different parts of the solution, e.g. I'll experiment and see how it looks/feels. |
Since there are things that can go wrong when checking out a PR branch, I thought it would be best if we point the user the right direction (and let them continue down that workflow) rather than automatically initiating a checkout. The next commit will make it pop up a simple dialog when it detects the user is on a different branch to the PR diff file: This is similar to what MS does when user tries to Does that make sense? |
Stop user from opening solution files that aren't related to the target PR diff file.
|
I think this is looking great @jcansdale 🙌 . I like the most recent change you made with the prompt to checkout a branch first. It's a good reminder for users to be on the branch before making any changes. Also, it's really easy to switch between the diff view and editor (as long as you know how to do so!) and it reminds me a lot of how easy it is to switch between the diff and edit files on dotcom as well. The hardest part with this feature is discoverability... The menu item you added on right-click is nice if users know to look there, but I don't think they will. I really like the earlier idea you suggested of an "explicit edit button on the inline comment view". Although that would seem to tie this feature with inline comments, at least there will be a visible option to switch between the diff and editor. |
|
I've been playing around with the built-in diff view in VS, and it looks like it supports what the original goal of this PR (being able to edit a file from a diff): I might need a refresher, but is there a reason why we are using read-only diffs in this situation? Is it to prevent losing the review comments? Can we consider scoping this feature to only diffs with comments in them? |
|
@donokuda I've added the following under related issues:
I'll flesh out some more when I'm back on Monday... |
Make the `Open File in Solution` command and keyboard shortcut discoverable by advertising on the inline comment view task bar.
6155644 to
9857cdc
Compare
Was rough and non-functional! This reverts commit 9857cdc.
When target line has changed, search for alternative exact line matches above and use matched line as offset.
df9a51a to
81c53cc
Compare
Done
Done
This PR now targets I hope |
Move service class/interface to GitHub.Exports.Reactive project.
5fe8d0d to
b95c2ff
Compare
|
@grokys, Okay, I've renamed/moved |
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.
Just a nit about a doc comment, but other than that LGTM!
| namespace GitHub.VisualStudio.Views.GitHubPane | ||
| { | ||
| /// <summary> | ||
| /// Used to filter commands send to <see cref="IVsTextView"/> dispatch them to a <see cref="Exec"/> event. |
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.
This sentence doesn't make sense grammatically. Also might be useful to say why this class is needed in the <remarks>? That is, why do commands need to be filtered (and?) dispatched to a(n) Exec event?
9e4af59 to
c3da975
Compare
Enable navigation from diff view to editor
Enable navigation from diff view to editor
Enable navigation from diff view to editor






Functionality
MVP
Enterkey when in PR file diff view (double-click on PR file)Enterkey when in PR file view (right-click on PR file andView File)Open in Solution File{line likely wouldn't be).Open Solution File at Caretcommand and keyboard shortcut on inline comment viewScreengrabs
The
Open in Solution Filecommand is surfaced on the code context menu:Attempting to open a PR file that isn't checked out will bring up this:
Open Solution file command and keyboard shortcut is discoverable on Inline Comment task bar
To do
Discoverability
Moving this to separate issue / PR:
At the moment there is no visual indication that this feature exists. The user must open a PR diff file and know to hit the
Enterkey.The
Enterkey is used for navigation to source files in a number of contexts inside Visual Studio. It can be used to navigate to the selected file from Solution Explorer or to a displayed file, line and column from the Output window (e.g. for build errors). It is also used by theChangestree view inside Team Explorer, but currently not on our GitHubChangestree.To make it more discoverable we might:
Go To Working Filecommand on the code context menuRelated issues