Skip to content

Allow to open either side of a diff editor as editor (fix #153786)#165765

Merged
bpasero merged 5 commits intomicrosoft:mainfrom
jasonwilliams:openFileFromDiff
Dec 12, 2022
Merged

Allow to open either side of a diff editor as editor (fix #153786)#165765
bpasero merged 5 commits intomicrosoft:mainfrom
jasonwilliams:openFileFromDiff

Conversation

@jasonwilliams
Copy link
Contributor

@jasonwilliams jasonwilliams commented Nov 7, 2022

This is an attempt to implement #153786 by offering a way of going back to a single window from a diff. It should also be possible to display either side of the diff in a single window (other editors allow this).

When doing code reviews on GitHub you can open a file fully for context, then click back into the diff when done viewing. It should be just as easy to do this in VSCode.

This change would greatly improve productivity as it helps with navigating around changes and not needing to learn different keybindings/commands from other extensions.

Things that are needed:

  • To know which side of the diff has focus so I can open the right file, currently this doesn't seem possible as neither textDiffEditor nor diffEditorInput support showing which side has focus.
  • Back currently doesn't work, once you open up an editor you can't go back to the diff view Addressed in [Bug] Diff Editors are not in the back/forward history #166805
  • Eventually an opportunity for a keybinding to open a window for each split you’re focused on. This increases productivity quite a bit as you can view the full file for context then go back to the diff.

diffToSingle

@bpasero bpasero assigned bpasero and unassigned alexdima Nov 8, 2022
@bpasero bpasero added this to the Backlog milestone Nov 8, 2022
@bpasero
Copy link
Member

bpasero commented Nov 8, 2022

Thanks for the PR, I can not guarantee a speedy reply on this, please be patient.

@jasonwilliams
Copy link
Contributor Author

jasonwilliams commented Nov 18, 2022

I've made some good progress on this, thanks to @eamodio's help.
The only issue remaining is you can't go back to a diff editor (I'm not sure why history doesn't support it). But this isn't related to this PR, it doesn't seem you could ever do that.

This also sets up the unused ctrl/cmd + k, shift + O to open either side.

Here's a gif:
diffToSingle2

Edit:
For some reason diff views get removed from the stack when you navigate away from one. Compare Selected always opens a new tab so its easy to go back, but once that tab is closed you can never reopen that diff in the history.

When changing that to group editor it seems the diffEditor is disposed once closed and cannot be re-opened. I assume this was intentional.

@jasonwilliams
Copy link
Contributor Author

jasonwilliams commented Nov 19, 2022

As the above bug seems to have always been there and is separate to this, ive raised a new issue

Awaiting @bpasero to advise.

@jasonwilliams jasonwilliams changed the title open single editor from diff view (help needed) fix #153786 open single editor from diff view fix #153786 Nov 19, 2022
@jasonwilliams jasonwilliams force-pushed the openFileFromDiff branch 2 times, most recently from 82ca40a to 75376da Compare November 26, 2022 08:38
Copy link
Member

@bpasero bpasero left a comment

Choose a reason for hiding this comment

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

Why does this replace the PIN_EDITOR_COMMAND_ID command?

@bpasero bpasero added the info-needed Issue requires more information from poster label Dec 6, 2022
@jasonwilliams
Copy link
Contributor Author

@bpasero you're right that looks like a mistake, I think I was experimenting there and didn't change it back before committing.
I've both fixed it and rebased.

@bpasero bpasero removed the info-needed Issue requires more information from poster label Dec 6, 2022
@jasonwilliams jasonwilliams requested a review from bpasero December 6, 2022 15:32
@bpasero bpasero changed the title open single editor from diff view fix #153786 Allow to open either side of a diff editor as editor (fix #153786) Dec 7, 2022
@bpasero bpasero added the info-needed Issue requires more information from poster label Dec 8, 2022
@jasonwilliams
Copy link
Contributor Author

Hey @bpasero let me know what you think of the changes, I've hopefully addressed both of your points above.

@bpasero bpasero removed the info-needed Issue requires more information from poster label Dec 12, 2022
@bpasero bpasero modified the milestones: Backlog, January 2023 Dec 12, 2022
@bpasero
Copy link
Member

bpasero commented Dec 12, 2022

Thanks. I cleaned it up a little.

@bpasero bpasero enabled auto-merge (squash) December 12, 2022 07:31
@bpasero bpasero merged commit 7c721a0 into microsoft:main Dec 12, 2022
@jasonwilliams
Copy link
Contributor Author

jasonwilliams commented Dec 12, 2022

Thanks for reviewing @bpasero @alexdima

Are you able to offer any guidance to #166805? It feels a bit broken that you can navigate to a diff side but can’t go back.
Is there a reason diffEditors were never added to the history stack? It would be useful to fix this so navigation properly works (for reviewing changes between diff and full file).

@bpasero
Copy link
Member

bpasero commented Dec 12, 2022

I think we only keep editors in the history that can be addressed via plain old JS objects (e.g. { resource: <uri> }), not fully heavy typed editor inputs. We cannot know for sure that a closed editor can be restored from its EditorInput because it is disposed after being closed.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 27, 2023
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.

3 participants