Skip to content

Show unsaved file modifications by opening a diff view#30210

Merged
bpasero merged 2 commits into
microsoft:masterfrom
tfriem:ShowModifications
Jul 10, 2017
Merged

Show unsaved file modifications by opening a diff view#30210
bpasero merged 2 commits into
microsoft:masterfrom
tfriem:ShowModifications

Conversation

@tfriem

@tfriem tfriem commented Jul 6, 2017

Copy link
Copy Markdown
Contributor

The feature requested in #358.

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

@msftclas

msftclas commented Jul 6, 2017

Copy link
Copy Markdown

@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

msftclas commented Jul 6, 2017

Copy link
Copy Markdown

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

Thanks, Microsoft Pull Request Bot

@bpasero bpasero left a comment

Copy link
Copy Markdown
Contributor

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 👍

revertAction.enabled = openEditor.isDirty();
result.push(revertAction);

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

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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);

}

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

@bpasero bpasero Jul 7, 2017

Copy link
Copy Markdown
Contributor

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

tfriem commented Jul 7, 2017

Copy link
Copy Markdown
Contributor Author

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

bpasero commented Jul 10, 2017

Copy link
Copy Markdown
Contributor

Thanks, merged 👍

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

Copy link
Copy Markdown

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

bpasero commented Aug 14, 2017

Copy link
Copy Markdown
Contributor

@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
Copy Markdown

@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.

5 participants