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

Show unsaved file modifications by opening a diff view #30210

Merged
merged 2 commits into from
Jul 10, 2017
Merged

Show unsaved file modifications by opening a diff view #30210

merged 2 commits into from
Jul 10, 2017

Conversation

tfriem
Copy link
Contributor

@tfriem tfriem commented Jul 6, 2017

The feature requested in #358.

The diff view can be opened from the context menu of the open editors items.

@msftclas
Copy link

msftclas commented Jul 6, 2017

@tfriem,
Thanks for your contribution.
To ensure that the project team has proper rights to use your work, please complete the Contribution License Agreement at https://cla.microsoft.com.

It will cover your contributions to all Microsoft-managed open source projects.
Thanks,
Microsoft Pull Request Bot

@msftclas
Copy link

msftclas commented Jul 6, 2017

@tfriem, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request.

Thanks, Microsoft Pull Request Bot

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.

@tfriem very good start, some feedback provided 👍

@@ -375,6 +375,11 @@ export class ActionProvider extends ContributableActionProvider {
revertAction.setResource(resource);
revertAction.enabled = openEditor.isDirty();
result.push(revertAction);

const showModificationsAction = this.instantiationService.createInstance(ShowModificationsAction, ShowModificationsAction.ID, ShowModificationsAction.LABEL);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe rename this to "Compare with Saved" to make it clear what it does? And then we could maybe move this command into the place where today we have "Select for Compare"?

image


public run(): TPromise<any> {
if (this.resource) {
return this.editorService.openEditor({ leftResource: URI.from({ scheme: SHOW_MODIFICATIONS_SCHEME, path: this.resource.fsPath }), rightResource: this.resource, label: nls.localize('Modifications', "Modifications"), options: { pinned: true } });
Copy link
Member

Choose a reason for hiding this comment

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

I am not 100% sure about pinned: true, maybe we should not set this so that multiple comparisons done after each other do not add up tabs?


public run(): TPromise<any> {
if (this.resource) {
return this.editorService.openEditor({ leftResource: URI.from({ scheme: SHOW_MODIFICATIONS_SCHEME, path: this.resource.fsPath }), rightResource: this.resource, label: nls.localize('Modifications', "Modifications"), options: { pinned: true } });
Copy link
Member

Choose a reason for hiding this comment

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

I suggest to find a better title for the tab, "Modifications" is very generic. I suggest something similar to the diff editor:

const name = paths.basename(resource.fsPath);
const editorLabel = nls.localize('modifiedLabel', "{0} (on disk) ↔ {1}", name, name);

@@ -1990,6 +1993,58 @@ export function getWellFormedFileName(filename: string): string {
return filename;
}

export const SHOW_MODIFICATIONS_SCHEME = 'showModifications';
export class ShowModificationsAction extends Action implements ITextModelContentProvider {
Copy link
Member

@bpasero bpasero Jul 7, 2017

Choose a reason for hiding this comment

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

I suggest to also make this action available via keybinding and command list (Cmd+Shift+P). As such it should be registered as a global action and in that case just use the current active editor as thing to compare. The action would simply do nothing if there is no active file opened or that file is not dirty.

@bpasero bpasero self-assigned this Jul 7, 2017
@bpasero bpasero added this to the On Deck milestone Jul 7, 2017
- Context menu item text changed
- Tab title changed
- Keybinding added (Ctrl + K, D)
- Pinning removed
@tfriem
Copy link
Contributor Author

tfriem commented Jul 7, 2017

Thanks for the extensive feedback. The new version should address all the points.

@bpasero bpasero modified the milestones: July 2017, On Deck Jul 8, 2017
@bpasero bpasero merged commit ecdb907 into microsoft:master Jul 10, 2017
@bpasero
Copy link
Member

bpasero commented Jul 10, 2017

Thanks, merged 👍

@tfriem tfriem deleted the ShowModifications branch July 10, 2017 05:48
@clankill3r
Copy link

I would love to see that it also can be used from 'Folders' instead of only 'Open Editors'.
I prefer to have the 'Open Editors' removed from the sidebar. But then I can't use 'Compared with saved' from the right click menu.

@bpasero
Copy link
Member

bpasero commented Aug 14, 2017

@clankill3r there is a global action that you can either use via F1 or keybinding and it will work on the currently active file.

@alexwhittemore
Copy link

@tfriem Thanks for this! I love it when I search for "can VSCode do " and I find the PR describing the functionality and how to use it :)

@microsoft microsoft locked and limited conversation to collaborators Mar 20, 2019
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.

None yet

5 participants