-
Notifications
You must be signed in to change notification settings - Fork 30.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
Expose diffEditor to plugins #1865
Comments
Yes, just talked about this with @jrieken |
@bpasero Given virtual document etc and the API command, can't we just expose the underlying command? |
@jrieken the command I am using in the explorer currently only works with files that exists on disk (https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/parts/files/browser/fileActions.ts#L1270). we would have to introduce a new command that can deal with any resource and then use it from that action too. |
k. seems easy, let's do that in May |
Something like this seems to work already: extHostApiComands this._register('vscode.diff', (left: URI, right: URI, label: string) => {
return this._commands.executeCommand('_workbench.diff', left, right, label);
}, {
description: 'Opens the provided resources in the diff editor to compare their contents.',
args: [
{ name: 'left', description: 'Uri of the resource for the left hand side of the diff editor', constraint: value => value instanceof URI },
{ name: 'right', description: 'Uri of the resource for the right hand side of the diff editor', constraint: value => value instanceof URI },
{ name: 'label', description: 'Label to use for the diff editor', constraint: value => typeof value === 'string' }
]
}); electron-browser/actions KeybindingsRegistry.registerCommandDesc({
id: '_workbench.diff',
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(0),
handler(accessor: ServicesAccessor, args: [URI, URI, string]) {
const instantiationService = accessor.get(IInstantiationService);
const editorService = accessor.get(IWorkbenchEditorService);
const left = instantiationService.createInstance(ResourceEditorInput, nls.localize('left', "Left"), null, args[0]);
const right = instantiationService.createInstance(ResourceEditorInput, nls.localize('right', "Right"), null, args[1]);
const diff = new DiffEditorInput(args[2], null, left, right);
return editorService.openEditor(diff);
},
context: undefined,
primary: undefined
}); |
If we provide a normal file URI to this API (not a virtual document URI) will it work as expected? |
Good to see this newly added api then we may diff PR in VS Code. |
@daviwil Yes |
It would be nice to be able to open the diffEditor in a plugin. At the moment, I determine the diff myself in
vscode-yo
if a conflict arrises. But the diffEditor of Code is much more powerfull and shows the diffs very nicely. Is this a possibility?// @bpasero
The text was updated successfully, but these errors were encountered: