-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
Conversation
@tfriem, It will cover your contributions to all Microsoft-managed open source projects. |
@tfriem, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request. |
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.
@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); |
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.
|
||
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 } }); |
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.
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 } }); |
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.
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 { |
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.
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.
- Context menu item text changed - Tab title changed - Keybinding added (Ctrl + K, D) - Pinning removed
Thanks for the extensive feedback. The new version should address all the points. |
Thanks, merged 👍 |
I would love to see that it also can be used from 'Folders' instead of only 'Open Editors'. |
@clankill3r there is a global action that you can either use via F1 or keybinding and it will work on the currently active file. |
@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 :) |
The feature requested in #358.
The diff view can be opened from the context menu of the open editors items.